forked from mtusi2026/mtusi2026lab2
130 lines
12 KiB
Plaintext
130 lines
12 KiB
Plaintext
chat/insert_100000 (EXPLAIN JSON)
|
|
{"Plan": {"Node Type": "ModifyTable", "Operation": "Insert", "Parallel Aware": false, "Async Capable": false, "Relation Name": "messages", "Alias": "messages", "Startup Cost": 0.0, "Total Cost": 5750.0, "Plan Rows": 0, "Plan Width": 0, "Actual Startup Time": 991.526, "Actual Total Time": 991.527, "Actual Rows": 0, "Actual Loops": 1, "Shared Hit Blocks": 545161, "Shared Read Blocks": 2, "Shared Dirtied Blocks": 3466, "Shared Written Blocks": 3466, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 171, "Temp Written Blocks": 171, "WAL Records": 301651, "WAL FPI": 0, "WAL Bytes": 41896134, "Plans": [{"Node Type": "Function Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Function Name": "generate_series", "Alias": "g", "Startup Cost": 0.0, "Total Cost": 5750.0, "Plan Rows": 100000, "Plan Width": 88, "Actual Startup Time": 11.145, "Actual Total Time": 172.283, "Actual Rows": 100000, "Actual Loops": 1, "Shared Hit Blocks": 0, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 171, "Temp Written Blocks": 171, "WAL Records": 0, "WAL FPI": 0, "WAL Bytes": 0}]}, "Planning": {"Shared Hit Blocks": 15, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0}, "Planning Time": 0.141, "Triggers": [{"Trigger Name": "RI_ConstraintTrigger_c_16443", "Constraint Name": "messages_chat_id_fkey", "Relation": "messages", "Time": 301.956, "Calls": 100000}, {"Trigger Name": "RI_ConstraintTrigger_c_16448", "Constraint Name": "messages_chat_id_sender_id_fkey", "Relation": "messages", "Time": 319.258, "Calls": 100000}], "Execution Time": 1623.789}
|
|
|
|
chat/hot_first
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='6adca606-cb42-ce80-9dfe-e9c5ab3f1b51' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+0*interval '1 millisecond','00000000-0000-0000-0000-000000000000'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=8700.40..8700.53 rows=51 width=257) (actual time=30.996..31.003 rows=51 loops=1)
|
|
Buffers: shared hit=2862
|
|
-> Sort (cost=8700.40..8899.13 rows=79492 width=257) (actual time=30.994..30.998 rows=51 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 50kB
|
|
Buffers: shared hit=2862
|
|
-> Seq Scan on messages (cost=0.00..6048.38 rows=79492 width=257) (actual time=0.018..20.924 rows=80000 loops=1)
|
|
Filter: ((chat_id = '6adca606-cb42-ce80-9dfe-e9c5ab3f1b51'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:00:00'::interval), '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Rows Removed by Filter: 20000
|
|
Buffers: shared hit=2856
|
|
Planning:
|
|
Buffers: shared hit=101
|
|
Planning Time: 0.309 ms
|
|
Execution Time: 31.050 ms
|
|
|
|
chat/hot_deep
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='6adca606-cb42-ce80-9dfe-e9c5ab3f1b51' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+70000*interval '1 millisecond','51007766-120b-9354-54a6-dc1c61f4f185'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=6024.82..6024.94 rows=51 width=257) (actual time=14.114..14.122 rows=51 loops=1)
|
|
Buffers: shared hit=2862
|
|
-> Sort (cost=6024.82..6085.24 rows=24168 width=257) (actual time=14.112..14.116 rows=51 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 50kB
|
|
Buffers: shared hit=2862
|
|
-> Seq Scan on messages (cost=0.00..5218.52 rows=24168 width=257) (actual time=8.013..12.721 rows=10000 loops=1)
|
|
Filter: ((chat_id = '6adca606-cb42-ce80-9dfe-e9c5ab3f1b51'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:01:10'::interval), '51007766-120b-9354-54a6-dc1c61f4f185'::uuid)))
|
|
Rows Removed by Filter: 90000
|
|
Buffers: shared hit=2856
|
|
Planning:
|
|
Buffers: shared hit=101
|
|
Planning Time: 0.247 ms
|
|
Execution Time: 14.167 ms
|
|
|
|
chat/small_deep
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='0edbe356-1e20-7355-3db8-96e0eb8b4f65' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+99000*interval '1 millisecond','ed7d9f1e-ca01-40c0-5d78-abf027268fa3'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=3091.06..3091.19 rows=51 width=257) (actual time=0.721..0.725 rows=51 loops=1)
|
|
Buffers: shared hit=155
|
|
-> Sort (cost=3091.06..3091.19 rows=54 width=257) (actual time=0.720..0.722 rows=51 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 50kB
|
|
Buffers: shared hit=155
|
|
-> Bitmap Heap Scan on messages (cost=58.38..3089.50 rows=54 width=257) (actual time=0.387..0.581 rows=1000 loops=1)
|
|
Recheck Cond: (chat_id = '0edbe356-1e20-7355-3db8-96e0eb8b4f65'::uuid)
|
|
Filter: (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:01:39'::interval), 'ed7d9f1e-ca01-40c0-5d78-abf027268fa3'::uuid))
|
|
Rows Removed by Filter: 4000
|
|
Heap Blocks: exact=144
|
|
Buffers: shared hit=149
|
|
-> Bitmap Index Scan on research_chat_idx (cost=0.00..58.37 rows=5077 width=0) (actual time=0.070..0.071 rows=5000 loops=1)
|
|
Index Cond: (chat_id = '0edbe356-1e20-7355-3db8-96e0eb8b4f65'::uuid)
|
|
Buffers: shared hit=5
|
|
Planning:
|
|
Buffers: shared hit=101
|
|
Planning Time: 0.210 ms
|
|
Execution Time: 0.762 ms
|
|
|
|
composite/insert_100000 (EXPLAIN JSON)
|
|
{"Plan": {"Node Type": "ModifyTable", "Operation": "Insert", "Parallel Aware": false, "Async Capable": false, "Relation Name": "messages", "Alias": "messages", "Startup Cost": 0.0, "Total Cost": 5750.0, "Plan Rows": 0, "Plan Width": 0, "Actual Startup Time": 656.964, "Actual Total Time": 656.965, "Actual Rows": 0, "Actual Loops": 1, "Shared Hit Blocks": 520819, "Shared Read Blocks": 2, "Shared Dirtied Blocks": 4222, "Shared Written Blocks": 4222, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 171, "Temp Written Blocks": 171, "WAL Records": 301359, "WAL FPI": 0, "WAL Bytes": 45729460, "Plans": [{"Node Type": "Function Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Function Name": "generate_series", "Alias": "g", "Startup Cost": 0.0, "Total Cost": 5750.0, "Plan Rows": 100000, "Plan Width": 88, "Actual Startup Time": 7.165, "Actual Total Time": 145.253, "Actual Rows": 100000, "Actual Loops": 1, "Shared Hit Blocks": 0, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 171, "Temp Written Blocks": 171, "WAL Records": 0, "WAL FPI": 0, "WAL Bytes": 0}]}, "Planning": {"Shared Hit Blocks": 15, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0}, "Planning Time": 0.104, "Triggers": [{"Trigger Name": "RI_ConstraintTrigger_c_16443", "Constraint Name": "messages_chat_id_fkey", "Relation": "messages", "Time": 298.604, "Calls": 100000}, {"Trigger Name": "RI_ConstraintTrigger_c_16448", "Constraint Name": "messages_chat_id_sender_id_fkey", "Relation": "messages", "Time": 321.92, "Calls": 100000}], "Execution Time": 1289.336}
|
|
|
|
composite/hot_first
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='6adca606-cb42-ce80-9dfe-e9c5ab3f1b51' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+0*interval '1 millisecond','00000000-0000-0000-0000-000000000000'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=0.42..11.17 rows=51 width=257) (actual time=0.032..0.047 rows=51 loops=1)
|
|
Buffers: shared hit=5
|
|
-> Index Scan using messages_history_idx on messages (cost=0.42..16911.78 rows=80205 width=257) (actual time=0.032..0.044 rows=51 loops=1)
|
|
Index Cond: ((chat_id = '6adca606-cb42-ce80-9dfe-e9c5ab3f1b51'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:00:00'::interval), '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Buffers: shared hit=5
|
|
Planning:
|
|
Buffers: shared hit=112
|
|
Planning Time: 0.264 ms
|
|
Execution Time: 0.078 ms
|
|
|
|
composite/hot_deep
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='6adca606-cb42-ce80-9dfe-e9c5ab3f1b51' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+70000*interval '1 millisecond','51007766-120b-9354-54a6-dc1c61f4f185'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=0.42..28.28 rows=51 width=257) (actual time=0.038..0.051 rows=51 loops=1)
|
|
Buffers: shared hit=6
|
|
-> Index Scan using messages_history_idx on messages (cost=0.42..13055.69 rows=23899 width=257) (actual time=0.037..0.047 rows=51 loops=1)
|
|
Index Cond: ((chat_id = '6adca606-cb42-ce80-9dfe-e9c5ab3f1b51'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:01:10'::interval), '51007766-120b-9354-54a6-dc1c61f4f185'::uuid)))
|
|
Buffers: shared hit=6
|
|
Planning:
|
|
Buffers: shared hit=112
|
|
Planning Time: 0.248 ms
|
|
Execution Time: 0.083 ms
|
|
|
|
composite/small_deep
|
|
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
|
|
SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages
|
|
WHERE chat_id='0edbe356-1e20-7355-3db8-96e0eb8b4f65' AND (created_at,id)>(
|
|
'2026-01-01T00:00:00Z'::timestamptz+99000*interval '1 millisecond','ed7d9f1e-ca01-40c0-5d78-abf027268fa3'::uuid)
|
|
ORDER BY messages.created_at,messages.id LIMIT 51;
|
|
Limit (cost=170.75..170.86 rows=45 width=257) (actual time=0.463..0.468 rows=51 loops=1)
|
|
Buffers: shared hit=50
|
|
-> Sort (cost=170.75..170.86 rows=45 width=257) (actual time=0.462..0.465 rows=51 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 50kB
|
|
Buffers: shared hit=50
|
|
-> Bitmap Heap Scan on messages (cost=4.88..169.51 rows=45 width=257) (actual time=0.115..0.305 rows=1000 loops=1)
|
|
Recheck Cond: ((chat_id = '0edbe356-1e20-7355-3db8-96e0eb8b4f65'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:01:39'::interval), 'ed7d9f1e-ca01-40c0-5d78-abf027268fa3'::uuid)))
|
|
Heap Blocks: exact=29
|
|
Buffers: shared hit=44
|
|
-> Bitmap Index Scan on messages_history_idx (cost=0.00..4.87 rows=45 width=0) (actual time=0.105..0.105 rows=1000 loops=1)
|
|
Index Cond: ((chat_id = '0edbe356-1e20-7355-3db8-96e0eb8b4f65'::uuid) AND (ROW(created_at, id) > ROW(('2026-01-01 00:00:00+00'::timestamp with time zone + '00:01:39'::interval), 'ed7d9f1e-ca01-40c0-5d78-abf027268fa3'::uuid)))
|
|
Buffers: shared hit=15
|
|
Planning:
|
|
Buffers: shared hit=112
|
|
Planning Time: 0.290 ms
|
|
Execution Time: 0.512 ms
|