jsha / blocktogether

Share your blocks and subscribe to others'
GNU General Public License v3.0
330 stars 68 forks source link

Change Actions index #199

Closed jsha closed 9 years ago

jsha commented 9 years ago

Right now Actions has an index on (source_uid, status, type, created_at). But the common query used by Actions.js,

SELECT * FROM `Actions` WHERE `Actions`.`status`='pending' AND `Actions`.`source_uid`='XXXX' ORDER BY createdAt ASC LIMIT 100;

doesn't include a type, and so this query is expensive for users with many non-pending Actions. Add a new index on (source_uid, status, created_at) and delete the old one. This should also decrease index size.