Skip to content

Commit

Permalink
Improve follows table indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Mar 7, 2011
1 parent 878b5ec commit 433df53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions webapp/install/sql/build-db_mysql.sql
@@ -1,6 +1,6 @@
--
-- ThinkUp Database Creation Script
-- Auto-generated by thinkup/extras/scripts/migratedb script on 2011-01-27
-- Auto-generated by thinkup/extras/scripts/migratedb script on 2011-03-07
--

ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Expand Down Expand Up @@ -55,8 +55,9 @@ CREATE TABLE tu_follows (
active int(11) NOT NULL DEFAULT '1',
network varchar(20) NOT NULL DEFAULT 'twitter',
debug_api_call varchar(255) NOT NULL,
UNIQUE KEY user_id (user_id,follower_id,network),
KEY active (active)
UNIQUE KEY user_id (network,follower_id,user_id),
UNIQUE KEY network (network,last_seen),
KEY active (network,active)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
Expand Down Expand Up @@ -288,7 +289,7 @@ CREATE TABLE tu_users (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


-- Dump completed on 2011-01-27 13:25:28
-- Dump completed on 2011-03-07 9:55:25

--
-- Insert DB Version
Expand Down
@@ -0,0 +1,9 @@
--
-- Speed up queries on the follows table with better indexes
--

ALTER TABLE tu_follows DROP INDEX user_id, ADD UNIQUE user_id (network, follower_id, user_id);

ALTER TABLE tu_follows DROP INDEX active, ADD INDEX active (network, active);

ALTER TABLE tu_follows ADD UNIQUE (network, last_seen);

0 comments on commit 433df53

Please sign in to comment.