Skip to content

Instantly share code, notes, and snippets.

@lfittl
Created August 30, 2009 10:09
Show Gist options
  • Select an option

  • Save lfittl/177918 to your computer and use it in GitHub Desktop.

Select an option

Save lfittl/177918 to your computer and use it in GitHub Desktop.
soup_production=# EXPLAIN ANALYZE SELECT posts.id, created_at FROM posts WHERE posts.blog_id = 2 AND LANGUAGE IS NOT NULL AND NOT posts.deleted AND feed_id IS NULL AND TRUE ORDER BY posts.created_at DESC, posts.id DESC LIMIT 40;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=155.67..155.69 rows=37 width=16) (actual time=3747.996..3748.007 rows=40 loops=1)
-> Sort (cost=155.67..155.69 rows=37 width=16) (actual time=3747.994..3747.999 rows=40 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 26kB
-> Index Scan using posts_lastfm_check on posts (cost=0.00..155.48 rows=37 width=16) (actual time=18.383..3747.373 rows=496 loops=1)
Index Cond: ((feed_id IS NULL) AND (blog_id = 2))
Filter: ((language IS NOT NULL) AND (NOT deleted))
Total runtime: 3748.041 ms
soup_production=# EXPLAIN ANALYZE SELECT posts.id, created_at FROM posts WHERE posts.blog_id = 16665 AND LANGUAGE IS NOT NULL AND NOT posts.deleted AND feed_id IS NULL AND TRUE ORDER BY posts.created_at DESC, posts.id DESC LIMIT 40;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..2906.70 rows=40 width=16) (actual time=61233.956..83447.251 rows=40 loops=1)
-> Index Scan Backward using posts_for_one_soup on posts (cost=0.00..176436.71 rows=2428 width=16) (actual time=61233.956..83447.228 rows=40 loops=1)
Index Cond: (blog_id = 16665)
Filter: ((NOT deleted) AND (feed_id IS NULL))
Total runtime: 83447.289 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment