Skip to content

Instantly share code, notes, and snippets.

@t7y
Created May 11, 2011 18:38
Show Gist options
  • Save t7y/967030 to your computer and use it in GitHub Desktop.
Save t7y/967030 to your computer and use it in GitHub Desktop.
table partition
SET constraint_exclusion = on;
EXPLAIN (ANALYZE ON, BUFFERS ON) select * from daily_keyphrase_views_main WHERE writer_id = '585144' AND date BETWEEN '2011-01-01' AND '2011-01-31' AND partition_id = (585144 % 41);
Result (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.574..4492.705 rows=218272 loops=1)
Buffers: shared read=3275
-> Append (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.572..4405.989 rows=218272 loops=1)
Buffers: shared read=3275
-> Seq Scan on daily_keyphrase_views_main (cost=0.00..12.60 rows=1 width=556) (actual time=0.001..0.001 rows=0 loops=1)
Filter: ((date >= '2011-01-01'::date) AND (date <= '2011-01-31'::date) AND (writer_id = 585144) AND (partition_id = 33))
-> Bitmap Heap Scan on daily_keyphrase_views_p33 daily_keyphrase_views_main (cost=5242.27..16900.31 rows=220702 width=71) (actual time=857.569..4353.713 rows=218272 loops=1)
Recheck Cond: ((writer_id = 585144) AND (date >= '2011-01-01'::date) AND (date <= '2011-01-31'::date))
Filter: (partition_id = 33)
Buffers: shared read=3275
-> Bitmap Index Scan on index_daily_keyphrase_views_p33_on_writer_id_n_date (cost=0.00..5187.09 rows=220702 width=0) (actual time=822.326..822.326 rows=218272 loops=1)
Index Cond: ((writer_id = 585144) AND (date >= '2011-01-01'::date) AND (date <= '2011-01-31'::date))
Buffers: shared read=600
Total runtime: 4522.369 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment