Performance fix for subscription/subscriber lists based on feedback from ops.
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).
This commit is contained in:
parent
9d0687b055
commit
737fe76347
@ -45,3 +45,9 @@ create table login_token (
|
|||||||
alter table fave
|
alter table fave
|
||||||
drop index fave_user_id_idx,
|
drop index fave_user_id_idx,
|
||||||
add index fave_user_id_idx (user_id,modified);
|
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);
|
||||||
|
@ -51,3 +51,9 @@ create table login_token (
|
|||||||
alter table fave
|
alter table fave
|
||||||
drop index fave_user_id_idx,
|
drop index fave_user_id_idx,
|
||||||
add index fave_user_id_idx using btree(user_id,modified);
|
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);
|
||||||
|
@ -107,8 +107,8 @@ create table subscription (
|
|||||||
modified timestamp comment 'date this record was modified',
|
modified timestamp comment 'date this record was modified',
|
||||||
|
|
||||||
constraint primary key (subscriber, subscribed),
|
constraint primary key (subscriber, subscribed),
|
||||||
index subscription_subscriber_idx (subscriber),
|
index subscription_subscriber_idx (subscriber, created),
|
||||||
index subscription_subscribed_idx (subscribed),
|
index subscription_subscribed_idx (subscribed, created),
|
||||||
index subscription_token_idx (token)
|
index subscription_token_idx (token)
|
||||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ create table subscription (
|
|||||||
|
|
||||||
primary key (subscriber, subscribed)
|
primary key (subscriber, subscribed)
|
||||||
);
|
);
|
||||||
create index subscription_subscriber_idx on subscription using btree(subscriber);
|
create index subscription_subscriber_idx on subscription using btree(subscriber,created);
|
||||||
create index subscription_subscribed_idx on subscription using btree(subscribed);
|
create index subscription_subscribed_idx on subscription using btree(subscribed,created);
|
||||||
|
|
||||||
create sequence notice_seq;
|
create sequence notice_seq;
|
||||||
create table notice (
|
create table notice (
|
||||||
|
Loading…
Reference in New Issue
Block a user