]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Performance fix for subscription/subscriber lists based on feedback from ops.
authorBrion Vibber <brion@pobox.com>
Tue, 10 Nov 2009 16:47:54 +0000 (08:47 -0800)
committerBrion Vibber <brion@pobox.com>
Tue, 10 Nov 2009 16:47:54 +0000 (08:47 -0800)
Extended subscription table indexes for subscriber and subscribed to include the created field, which is used to sort for display. This lets us skip a filesort and do the join much more efficiently.
Alter table from 08to09.sql needs to be run manually (though no ill effects if you forget other than not getting the perf improvement).

db/08to09.sql
db/08to09_pg.sql
db/statusnet.sql
db/statusnet_pg.sql

index e6842225bb34fd955bfde1aef934712aae64cc0c..1d37a759d8429ca1b347e6439553394caba30f5a 100644 (file)
@@ -45,3 +45,9 @@ create table login_token (
 alter table fave
     drop index fave_user_id_idx,
     add index fave_user_id_idx (user_id,modified);
+
+alter table subscription
+    drop index subscription_subscriber_idx,
+    add index subscription_subscriber_idx (subscriber,created),
+    drop index subscription_subscribed_idx,
+    add index subscription_subscribed_idx (subscribed,created);
index 956c4dee55dc841c7df77cd726e66a0fe60b7d08..004c77b365dd657ab14eeaa612f4fd38317ef6cd 100644 (file)
@@ -51,3 +51,9 @@ create table login_token (
 alter table fave
     drop index fave_user_id_idx,
     add index fave_user_id_idx using btree(user_id,modified);
+
+alter table subscription
+    drop index subscription_subscriber_idx,
+    add index subscription_subscriber_idx using btree(subscriber,created),
+    drop index subscription_subscribed_idx,
+    add index subscription_subscribed_idx using btree(subscribed,created);
index 510c8866efe2be190d37fbf9404f613ed4f2df89..2983c67cfc00c9543b942bfced0d21ae14d7c99f 100644 (file)
@@ -107,8 +107,8 @@ create table subscription (
     modified timestamp comment 'date this record was modified',
 
     constraint primary key (subscriber, subscribed),
-    index subscription_subscriber_idx (subscriber),
-    index subscription_subscribed_idx (subscribed),
+    index subscription_subscriber_idx (subscriber, created),
+    index subscription_subscribed_idx (subscribed, created),
     index subscription_token_idx (token)
 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
 
index 710883e57dee3710d88b41382750d55ecb7480d0..392a6a5f3c29fada0afa2dec63e7671999fe7278 100644 (file)
@@ -115,8 +115,8 @@ create table subscription (
 
     primary key (subscriber, subscribed)
 );
-create index subscription_subscriber_idx on subscription using btree(subscriber);
-create index subscription_subscribed_idx on subscription using btree(subscribed);
+create index subscription_subscriber_idx on subscription using btree(subscriber,created);
+create index subscription_subscribed_idx on subscription using btree(subscribed,created);
 
 create sequence notice_seq;
 create table notice (