Commit e20392b3 authored by Leigh Stoller's avatar Leigh Stoller

Add a couple of indexes to the node_history to speed up the query.

Also, when calling with -A (showall) and -n (number of records),
lets not read the entire 5 million rows and then throw away everything
but the first 20. Takes about an hour.

In general this script needs some work.  Would also be nice to page
through records by specifying an index to start with.
parent 4b8e044b
......@@ -2376,7 +2376,9 @@ CREATE TABLE `node_history` (
`cnet_IP` varchar(15) default NULL,
`phys_nodeid` varchar(32) default NULL,
PRIMARY KEY (`history_id`),
KEY `node_id` (`node_id`,`history_id`)
KEY `node_id` (`node_id`,`history_id`),
INDEX `exptidx` (`exptidx`),
INDEX `stamp` (`stamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
......
#
# Add key to node_history.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBKeyExists("node_history", "exptidx")) {
DBQueryFatal("alter table node_history add " .
" INDEX exptidx (exptidx)");
}
if (!DBKeyExists("node_history", "stamp")) {
DBQueryFatal("alter table node_history add " .
" INDEX stamp (stamp)");
}
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
......@@ -173,13 +173,15 @@ elsif (defined($ip)) {
# XXX maybe it would be better to sort them here in perl, outside the DB?
my $orderby = " ORDER BY stamp ASC";
# Bogus, but reading the entire table is nuts! Millions of rows.
my $limitby = ($showall && $numrecs ? "limit " . $numrecs * 100 : "");
my $query_result =
DBQueryFatal("SELECT node_id,stamp,op,uid,pid,eid, ".
" experiment_stats.exptidx,cnet_ip,phys_nodeid ".
"FROM node_history,experiment_stats ".
"WHERE node_history.exptidx=experiment_stats.exptidx ".
"$querymod $orderby");
"$querymod $orderby $limitby");
my %nodeinfo; # [ expt, starttime, uid ]
my @records;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment