EXPLAIN ----------------- Limit (cost=7539.07..7539.19 rows=50 width=12) -> Sort (cost=7539.07..7539.76 rows=276 width=12) Sort Key: pop.cnt -> Hash Join (cost=6738.60..7527.88 rows=276 width=12) Hash Cond: (ss.story_id = s.id) -> Seq Scan on news_stories_sites ss (cost=0.00..656.25 rows=34740 width=4) Filter: (site_id = 1) -> Hash (cost=6735.15..6735.15 rows=276 width=16) -> Nested Loop (cost=4773.44..6735.15 rows=276 width=16) -> HashAggregate (cost=4773.44..4778.13 rows=375 width=8) -> Seq Scan on mostpopular_mostpopularhits (cost=0.00..4713.34 rows=8014 width=8) Filter: ((content_type_id = 61) AND (click_date >= '2008-04-15 15:00:00.685806+10'::timestamp with time zone) AND (click_date <= '2008-04-16 16:00:00.685833+10'::timestamp with time zone)) -> Index Scan using news_stories_pkey on news_stories s (cost=0.00..5.20 rows=1 width=4) Index Cond: (pop.object_id = s.id) Filter: ((status = 1) AND (pub_date <= now())) (15 rows) ---------------------------- EXPLAIN ANALYZE ---------------------------- Limit (cost=7539.07..7539.19 rows=50 width=12) (actual time=295.352..295.582 rows=50 loops=1) -> Sort (cost=7539.07..7539.76 rows=276 width=12) (actual time=295.348..295.417 rows=50 loops=1) Sort Key: pop.cnt -> Hash Join (cost=6738.60..7527.88 rows=276 width=12) (actual time=164.690..288.492 rows=3510 loops=1) Hash Cond: (ss.story_id = s.id) -> Seq Scan on news_stories_sites ss (cost=0.00..656.25 rows=34740 width=4) (actual time=0.060..60.333 rows=34740 loops=1) Filter: (site_id = 1) -> Hash (cost=6735.15..6735.15 rows=276 width=16) (actual time=163.103..163.103 rows=3510 loops=1) -> Nested Loop (cost=4773.44..6735.15 rows=276 width=16) (actual time=83.310..155.054 rows=3510 loops=1) -> HashAggregate (cost=4773.44..4778.13 rows=375 width=8) (actual time=83.177..90.455 rows=3512 loops=1) -> Seq Scan on mostpopular_mostpopularhits (cost=0.00..4713.34 rows=8014 width=8) (actual time=0.051..65.881 rows=7886 loops=1) Filter: ((content_type_id = 61) AND (click_date >= '2008-04-15 15:00:00.685806+10'::timestamp with time zone) AND (click_date <= '2008-04-16 16:00:00.685833+10'::timestamp with time zone)) -> Index Scan using news_stories_pkey on news_stories s (cost=0.00..5.20 rows=1 width=4) (actual time=0.010..0.012 rows=1 loops=3512) Index Cond: (pop.object_id = s.id) Filter: ((status = 1) AND (pub_date <= now())) Total runtime: 296.042 ms (16 rows)