Skip to content

Commit

Permalink
Creating indices on sqlite tables to drastically speed up lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
iangreenleaf committed Mar 11, 2010
1 parent e9603f4 commit fc88993
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Db/Classes.php
Expand Up @@ -15,11 +15,13 @@ public static function init()
$db = Scisr_Db::getDb();
$create = <<<EOS
CREATE TABLE IF NOT EXISTS Classes(filename text, class text);
CREATE INDEX IF NOT EXISTS Classes_index_filename ON Classes (class);
EOS;
$db->exec($create);

$create = <<<EOS
CREATE TABLE IF NOT EXISTS ClassRelationships(class text, is_a text);
CREATE INDEX IF NOT EXISTS ClassRelationships_index_is_a ON ClassRelationships (is_a);
EOS;
$db->exec($create);
}
Expand Down
1 change: 1 addition & 0 deletions Db/FileIncludes.php
Expand Up @@ -15,6 +15,7 @@ public static function init()
// Yes, I know this is not the most efficient or normalized. But I'm lazy.
$create = <<<EOS
CREATE TABLE IF NOT EXISTS FileIncludes(file text, included_file text);
CREATE INDEX IF NOT EXISTS FileIncludes_index_file ON FileIncludes (file);
EOS;
$db->exec($create);
}
Expand Down
1 change: 1 addition & 0 deletions Db/Files.php
Expand Up @@ -19,6 +19,7 @@ public static function init()
$db = Scisr_Db::getDb();
$create = <<<EOS
CREATE TABLE IF NOT EXISTS FileInfo (file text, parsed text);
CREATE INDEX IF NOT EXISTS Files_index_file ON FileInfo (file);
EOS;
$db->exec($create);
}
Expand Down
6 changes: 6 additions & 0 deletions Db/VariableTypes.php
Expand Up @@ -17,10 +17,16 @@ public static function init()
$db = Scisr_Db::getDb();
$create = <<<EOS
CREATE TABLE IF NOT EXISTS VariableTypes(filename text, scopeopen integer, variable text, type text, variable_pointer integer);
CREATE INDEX IF NOT EXISTS VariableTypes_index_filename ON VariableTypes (filename);
CREATE UNIQUE INDEX IF NOT EXISTS VariableTypes_index_filename_var_ptr ON VariableTypes (filename, variable_pointer);
CREATE INDEX IF NOT EXISTS VariableTypes_index_filename_var_scope ON VariableTypes (filename, scopeopen, variable);
EOS;
$db->exec($create);
$create = <<<EOS
CREATE TABLE GlobalVariables(filename text, scopeopen integer, variable text, variable_pointer integer);
CREATE INDEX IF NOT EXISTS GlobalVariables_index_filename ON GlobalVariables (filename);
CREATE UNIQUE INDEX IF NOT EXISTS GlobalVariables_index_filename_var_ptr ON GlobalVariables (filename, variable_pointer);
CREATE INDEX IF NOT EXISTS GlobalVariables_index_filename_var_scope ON GlobalVariables (filename, scopeopen, variable);
EOS;
$db->exec($create);
}
Expand Down

0 comments on commit fc88993

Please sign in to comment.