Skip to content

Instantly share code, notes, and snippets.

@acyuta
Created July 16, 2019 16:37
Show Gist options
  • Save acyuta/5ef74a44a873ee2be94269c369669d45 to your computer and use it in GitHub Desktop.
Save acyuta/5ef74a44a873ee2be94269c369669d45 to your computer and use it in GitHub Desktop.
bt2=# SET enable_seqscan = off;
SET
bt2=# explain(analyze, buffers) select distinct serial_number from telemetry;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unique (cost=0.56..29452499.56 rows=608 width=4) (actual time=1.886..75483.005 rows=874 loops=1)
Buffers: shared hit=68873 read=884486 dirtied=56
-> Index Only Scan using concurently on telemetry (cost=0.56..29347579.02 rows=41968215 width=4) (actual Buffers: shared hit=68873 read=884486 dirtied=56
time=1.884..71989.949 rows=42559723 loops=1)
Heap Fetches: 9134141
Planning Time: 0.280 ms
Execution Time: 75485.129 ms
(7 rows)
bt2=# SET enable_seqscan = on;
SET
bt2=# explain(analyze, buffers) select distinct serial_number from telemetry;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------
HashAggregate (cost=2962701.69..2962707.77 rows=608 width=4) (actual time=55724.390..55724.523 rows=874 loops=1)
Group Key: serial_number
Buffers: shared hit=106176 read=2331923
-> Seq Scan on telemetry (cost=0.00..2857781.15 rows=41968215 width=4) (actual time=0.011..18983.038 rows=42559723 loops=1)
Buffers: shared hit=106176 read=2331923
Planning Time: 0.149 ms
Execution Time: 55724.690 ms
(7 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment