Commit 6f5374bf authored by Robert Ricci's avatar Robert Ricci

More query speedups

parent 39353337
......@@ -2540,8 +2540,8 @@ sub MapNodeOSID($$)
# that *is* loaded.
#
my $o_result =
DBQueryWarn("select o1.* from os_info as o1 ".
"left join partitions as p on o1.osid=p.osid ".
DBQueryWarn("select o1.* from partitions as p ".
"left join os_info as o1 on o1.osid=p.osid ".
"left join os_info as o2 on o2.OS=o1.OS ".
"where p.node_id='$node' and o2.osid='$osid'");
......
......@@ -693,7 +693,8 @@ CREATE TABLE os_info (
mustclean tinyint(4) NOT NULL default '1',
op_mode varchar(20) NOT NULL default 'MINIMAL',
PRIMARY KEY (osname,pid),
KEY osid (osid)
KEY osid (osid),
KEY OS (OS)
) TYPE=MyISAM;
--
......@@ -807,7 +808,9 @@ CREATE TABLE projects (
pcremote_ok set('pcplab','pcron','pcwa') default NULL,
PRIMARY KEY (pid),
KEY unix_gid (unix_gid),
KEY approved (approved)
KEY approved (approved),
KEY approved_2 (approved),
KEY pcremote_ok (pcremote_ok)
) TYPE=MyISAM;
--
......@@ -1047,7 +1050,8 @@ CREATE TABLE users (
adminoff tinyint(4) default '0',
verify_key varchar(32) default NULL,
PRIMARY KEY (uid),
KEY unix_uid (unix_uid)
KEY unix_uid (unix_uid),
KEY status (status)
) TYPE=MyISAM;
--
......
......@@ -290,10 +290,11 @@ while (my %row = $db_result->fetchhash()) {
#
# A non-specific version. Try to map it.
# XXX - Should this use MapNodeOSID??
#
my $o_result =
DBQueryFatal("select o1.* from os_info as o1 ".
"left join partitions as p ".
DBQueryFatal("select o1.* from partitions as p ".
"left join os_info as o1 ".
" on o1.osid=p.osid ".
"left join os_info as o2 ".
" on o2.OS=o1.OS ".
......
......@@ -1095,8 +1095,8 @@ COMMAND_PROTOTYPE(doaccounts)
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
" UNIX_TIMESTAMP(u.usr_modified) "
"from users as u "
"left join group_membership as p on p.uid=u.uid "
"from group_membership as p "
"left join users as u on p.uid=u.uid "
"left join groups as g on p.pid=g.pid "
"where ((p.pid='%s' and p.gid='%s')) "
" and p.trust!='none' "
......@@ -1109,8 +1109,8 @@ COMMAND_PROTOTYPE(doaccounts)
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
" UNIX_TIMESTAMP(u.usr_modified) "
"from users as u "
"left join group_membership as p on p.uid=u.uid "
"from group_membership as p "
"left join users as u on p.uid=u.uid "
"left join groups as g on "
" p.pid=g.pid and p.gid=g.gid "
"where ((p.pid='%s')) and p.trust!='none' "
......@@ -1128,8 +1128,8 @@ COMMAND_PROTOTYPE(doaccounts)
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
" UNIX_TIMESTAMP(u.usr_modified) "
"from users as u "
"left join group_membership as p on p.uid=u.uid "
"from group_membership as p "
"left join users as u on p.uid=u.uid "
"left join groups as g on "
" p.pid=g.pid and p.gid=g.gid "
"where (p.pid='%s') and p.trust!='none' "
......
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