From 8c7ac32a13c77a7703e669370c825463f63f4345 Mon Sep 17 00:00:00 2001 From: Mike Hibler Date: Tue, 9 Aug 2011 11:49:26 -0600 Subject: [PATCH] Add vnode_id index to vinterfaces table. Part I of "Lessons learned from a 100K node experiment". nfree would run for hours trying to free 100K virtual nodes due to a slow query in Node::ReleaseSharedBandwidth(). Now it takes 5 minutes. There were other lessons as well, but they fall in the category of "rearranging deck chairs" since we are going to have to massively overhaul lots of infrastructure to support O(100000+) node experiments on a regular basis. --- sql/database-create.sql | 3 ++- sql/updates/4/251 | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 sql/updates/4/251 diff --git a/sql/database-create.sql b/sql/database-create.sql index fe73b2861..de19750df 100644 --- a/sql/database-create.sql +++ b/sql/database-create.sql @@ -4038,7 +4038,8 @@ CREATE TABLE `vinterfaces` ( `bandwidth` int(10) NOT NULL default '0', PRIMARY KEY (`node_id`,`unit`), KEY `bynode` (`node_id`,`iface`), - KEY `type` (`type`) + KEY `type` (`type`), + KEY `vnode_id` (`vnode_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- diff --git a/sql/updates/4/251 b/sql/updates/4/251 new file mode 100644 index 000000000..9bacf6d72 --- /dev/null +++ b/sql/updates/4/251 @@ -0,0 +1,18 @@ +# +# Add an index to vinterfaces to help speed up nfree of virtual nodes. +# Otherwise ReleaseSharedBandwith() query examines every row of vinterfaces. +# +use strict; +use libdb; + +sub DoUpdate($$$) +{ + my ($dbhandle, $dbname, $version) = @_; + + if (!DBKeyExists("vinterfaces", "vnode_id")) { + DBQueryFatal("ALTER TABLE vinterfaces " + "ADD KEY `vnode_id` (`vnode_id`)"); + } + return 0; +} +1; -- GitLab