diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-21 15:21:18 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-21 15:21:18 -0800 |
commit | f6ebe815382a61574df5f9452ee9a0ea4ae38f0c (patch) | |
tree | 508fe7eea757ef3821118fb88e25a1f03e554acd | |
parent | 5253a99d7abb27f7b17d6fdbc725498fbedd0aaa (diff) |
Performance fix for FriendFeed sup interface: MySQL query optimizer was doing a table scan on notice; explicit subquery makes it run much more efficiently, only scanning items within the period under consideration. Standard subquery should be PostgreSQL-compatible.
-rw-r--r-- | actions/sup.php | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/actions/sup.php b/actions/sup.php index 5daf0a1c1..4e428dfa5 100644 --- a/actions/sup.php +++ b/actions/sup.php @@ -66,10 +66,12 @@ class SupAction extends Action $divider = common_sql_date(time() - $seconds); $notice->query('SELECT profile_id, max(id) AS max_id ' . - 'FROM notice ' . + 'FROM ( ' . + 'SELECT profile_id, id FROM notice ' . ((common_config('db','type') == 'pgsql') ? 'WHERE extract(epoch from created) > (extract(epoch from now()) - ' . $seconds . ') ' : 'WHERE created > "'.$divider.'" ' ) . + ') AS latest ' . 'GROUP BY profile_id'); $updates = array(); |