87 lines
3.9 KiB
Plaintext
87 lines
3.9 KiB
Plaintext
Timing is on.
|
|
=== Grade 5: index comparison ===
|
|
NOTICE: table "bench_index_a" does not exist, skipping
|
|
DROP TABLE
|
|
Time: 1.402 ms
|
|
DROP TABLE
|
|
Time: 0.122 ms
|
|
NOTICE: table "bench_index_b" does not exist, skipping
|
|
SELECT 120000
|
|
Time: 100.016 ms
|
|
SELECT 120000
|
|
Time: 146.729 ms
|
|
CREATE INDEX
|
|
Time: 44.119 ms
|
|
CREATE INDEX
|
|
Time: 86.764 ms
|
|
VACUUM
|
|
Time: 139.424 ms
|
|
VACUUM
|
|
Time: 140.120 ms
|
|
=== Table and index sizes ===
|
|
variant | index_size
|
|
-------------------+------------
|
|
A: regular index | 6928 kB
|
|
B: covering index | 13 MB
|
|
(2 rows)
|
|
|
|
Time: 0.846 ms
|
|
=== Index A: large chat, deep page ===
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..19.65 rows=100 width=87) (actual time=0.030..0.046 rows=100 loops=1)
|
|
Buffers: shared hit=2 read=4
|
|
-> Index Scan using bench_a_history_idx on bench_index_a (cost=0.42..4303.33 rows=22377 width=87) (actual time=0.030..0.041 rows=100 loops=1)
|
|
Index Cond: ((chat_id = '66666666-6666-4666-8666-666666666661'::uuid) AND (created_at > '2026-01-01 00:01:00+00'::timestamp with time zone))
|
|
Buffers: shared hit=2 read=4
|
|
Planning:
|
|
Buffers: shared hit=32
|
|
Planning Time: 0.091 ms
|
|
Execution Time: 0.059 ms
|
|
(9 rows)
|
|
|
|
Time: 1.254 ms
|
|
=== Index B: large chat, deep page ===
|
|
QUERY PLAN
|
|
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..8.07 rows=100 width=87) (actual time=0.038..0.064 rows=100 loops=1)
|
|
Buffers: shared hit=1 read=5
|
|
-> Index Only Scan using bench_b_history_idx on bench_index_b (cost=0.42..1730.46 rows=22596 width=87) (actual time=0.037..0.058 rows=100 loops=1)
|
|
Index Cond: ((chat_id = '66666666-6666-4666-8666-666666666661'::uuid) AND (created_at > '2026-01-01 00:01:00+00'::timestamp with time zone))
|
|
Heap Fetches: 0
|
|
Buffers: shared hit=1 read=5
|
|
Planning:
|
|
Buffers: shared hit=18
|
|
Planning Time: 0.079 ms
|
|
Execution Time: 0.074 ms
|
|
(10 rows)
|
|
|
|
Time: 0.315 ms
|
|
=== Index A: small chat ===
|
|
QUERY PLAN
|
|
--------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..44.76 rows=100 width=87) (actual time=0.037..0.059 rows=100 loops=1)
|
|
Buffers: shared hit=3 read=3
|
|
-> Index Scan using bench_a_history_idx on bench_index_a (cost=0.42..3453.96 rows=7788 width=87) (actual time=0.037..0.052 rows=100 loops=1)
|
|
Index Cond: (chat_id = '66666666-6666-4666-8666-666666666663'::uuid)
|
|
Buffers: shared hit=3 read=3
|
|
Planning Time: 0.043 ms
|
|
Execution Time: 0.068 ms
|
|
(7 rows)
|
|
|
|
Time: 0.263 ms
|
|
=== Index B: small chat ===
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..8.02 rows=100 width=87) (actual time=0.023..0.074 rows=100 loops=1)
|
|
Buffers: shared hit=2 read=4
|
|
-> Index Only Scan using bench_b_history_idx on bench_index_b (cost=0.42..614.82 rows=8080 width=87) (actual time=0.022..0.067 rows=100 loops=1)
|
|
Index Cond: (chat_id = '66666666-6666-4666-8666-666666666663'::uuid)
|
|
Heap Fetches: 0
|
|
Buffers: shared hit=2 read=4
|
|
Planning Time: 0.042 ms
|
|
Execution Time: 0.085 ms
|
|
(8 rows)
|
|
|
|
Time: 0.308 ms
|