forked from mtusi2026/mtusi2026lab2
bench: трек 2 — планы запросов, стоимость записи, backup/restore со сверкой
plans.py: 121 120 сообщений (60k/15k/2k/80), 3 индекса x keyset/OFFSET x 3 размера чата, pgbench в отдельном контейнере; WAL на вставку детерминированно. backup_restore.py: pg_dump живой БД во время записи через API, восстановление в новый контейнер и volume, сверка MD5 по чатам, API на восстановленной БД. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a8c6af8c7d
commit
eb92e8e91e
@@ -0,0 +1,20 @@
|
||||
Limit (cost=1673.53..1673.58 rows=20 width=238) (actual time=14.400..14.407 rows=51.00 loops=1)
|
||||
Buffers: shared hit=2124 read=53
|
||||
-> Sort (cost=1673.53..1674.03 rows=202 width=238) (actual time=14.398..14.402 rows=51.00 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 44kB
|
||||
Buffers: shared hit=2124 read=53
|
||||
-> Bitmap Heap Scan on messages (cost=8.89..1665.79 rows=202 width=238) (actual time=13.229..14.305 rows=300.00 loops=1)
|
||||
Recheck Cond: (chat_id = $1)
|
||||
Filter: (ROW(created_at, id) > ROW($2, $3))
|
||||
Rows Removed by Filter: 59700
|
||||
Heap Blocks: exact=2118
|
||||
Buffers: shared hit=2118 read=53
|
||||
-> Bitmap Index Scan on messages_chat_only (cost=0.00..8.84 rows=606 width=0) (actual time=1.829..1.829 rows=60000.00 loops=1)
|
||||
Index Cond: (chat_id = $1)
|
||||
Index Searches: 1
|
||||
Buffers: shared read=53
|
||||
Planning:
|
||||
Buffers: shared hit=97
|
||||
Planning Time: 0.456 ms
|
||||
Execution Time: 14.511 ms
|
||||
@@ -0,0 +1,20 @@
|
||||
Limit (cost=1673.53..1673.58 rows=20 width=238) (actual time=4.411..4.418 rows=51.00 loops=1)
|
||||
Buffers: shared hit=571 read=14
|
||||
-> Sort (cost=1673.53..1674.03 rows=202 width=238) (actual time=4.410..4.413 rows=51.00 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 52kB
|
||||
Buffers: shared hit=571 read=14
|
||||
-> Bitmap Heap Scan on messages (cost=8.89..1665.79 rows=202 width=238) (actual time=4.306..4.361 rows=75.00 loops=1)
|
||||
Recheck Cond: (chat_id = $1)
|
||||
Filter: (ROW(created_at, id) > ROW($2, $3))
|
||||
Rows Removed by Filter: 14925
|
||||
Heap Blocks: exact=564
|
||||
Buffers: shared hit=565 read=14
|
||||
-> Bitmap Index Scan on messages_chat_only (cost=0.00..8.84 rows=606 width=0) (actual time=0.764..0.765 rows=15000.00 loops=1)
|
||||
Index Cond: (chat_id = $1)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=1 read=14
|
||||
Planning:
|
||||
Buffers: shared hit=97
|
||||
Planning Time: 0.339 ms
|
||||
Execution Time: 4.475 ms
|
||||
@@ -0,0 +1,20 @@
|
||||
Limit (cost=1673.53..1673.58 rows=20 width=238) (actual time=0.129..0.130 rows=1.00 loops=1)
|
||||
Buffers: shared hit=11 read=1
|
||||
-> Sort (cost=1673.53..1674.03 rows=202 width=238) (actual time=0.127..0.128 rows=1.00 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
Buffers: shared hit=11 read=1
|
||||
-> Bitmap Heap Scan on messages (cost=8.89..1665.79 rows=202 width=238) (actual time=0.104..0.104 rows=1.00 loops=1)
|
||||
Recheck Cond: (chat_id = $1)
|
||||
Filter: (ROW(created_at, id) > ROW($2, $3))
|
||||
Rows Removed by Filter: 79
|
||||
Heap Blocks: exact=4
|
||||
Buffers: shared hit=5 read=1
|
||||
-> Bitmap Index Scan on messages_chat_only (cost=0.00..8.84 rows=606 width=0) (actual time=0.064..0.064 rows=80.00 loops=1)
|
||||
Index Cond: (chat_id = $1)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=1 read=1
|
||||
Planning:
|
||||
Buffers: shared hit=97
|
||||
Planning Time: 0.368 ms
|
||||
Execution Time: 0.207 ms
|
||||
@@ -0,0 +1,10 @@
|
||||
Limit (cost=0.42..77.92 rows=20 width=237) (actual time=0.456..0.514 rows=51.00 loops=1)
|
||||
Buffers: shared hit=6 read=4
|
||||
-> Index Scan using messages_chat_keyset on messages (cost=0.42..783.20 rows=202 width=237) (actual time=0.451..0.504 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=6 read=4
|
||||
Planning:
|
||||
Buffers: shared hit=120
|
||||
Planning Time: 0.921 ms
|
||||
Execution Time: 0.636 ms
|
||||
@@ -0,0 +1,10 @@
|
||||
Limit (cost=0.42..77.92 rows=20 width=237) (actual time=0.087..0.114 rows=51.00 loops=1)
|
||||
Buffers: shared hit=5 read=2
|
||||
-> Index Scan using messages_chat_keyset on messages (cost=0.42..783.20 rows=202 width=237) (actual time=0.084..0.108 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=5 read=2
|
||||
Planning:
|
||||
Buffers: shared hit=110
|
||||
Planning Time: 0.551 ms
|
||||
Execution Time: 0.156 ms
|
||||
@@ -0,0 +1,10 @@
|
||||
Limit (cost=0.42..77.92 rows=20 width=237) (actual time=0.071..0.072 rows=1.00 loops=1)
|
||||
Buffers: shared hit=2 read=2
|
||||
-> Index Scan using messages_chat_keyset on messages (cost=0.42..783.20 rows=202 width=237) (actual time=0.069..0.070 rows=1.00 loops=1)
|
||||
Index Cond: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=2 read=2
|
||||
Planning:
|
||||
Buffers: shared hit=110
|
||||
Planning Time: 0.373 ms
|
||||
Execution Time: 0.112 ms
|
||||
@@ -0,0 +1,20 @@
|
||||
Limit (cost=6162.88..6165.20 rows=20 width=238) (actual time=12.084..15.940 rows=51.00 loops=1)
|
||||
Buffers: shared hit=4307
|
||||
-> Gather Merge (cost=6162.88..6186.40 rows=202 width=238) (actual time=12.082..15.934 rows=51.00 loops=1)
|
||||
Workers Planned: 2
|
||||
Workers Launched: 2
|
||||
Buffers: shared hit=4307
|
||||
-> Sort (cost=5162.85..5163.06 rows=84 width=238) (actual time=8.686..8.690 rows=44.33 loops=3)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 57kB
|
||||
Buffers: shared hit=4307
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 41kB
|
||||
Worker 1: Sort Method: quicksort Memory: 58kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..5160.17 rows=84 width=238) (actual time=1.775..8.612 rows=100.00 loops=3)
|
||||
Filter: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Rows Removed by Filter: 40273
|
||||
Buffers: shared hit=4277
|
||||
Planning:
|
||||
Buffers: shared hit=89
|
||||
Planning Time: 0.335 ms
|
||||
Execution Time: 16.001 ms
|
||||
@@ -0,0 +1,20 @@
|
||||
Limit (cost=6162.88..6165.20 rows=20 width=238) (actual time=19.403..27.573 rows=51.00 loops=1)
|
||||
Buffers: shared hit=4307
|
||||
-> Gather Merge (cost=6162.88..6186.40 rows=202 width=238) (actual time=19.400..27.552 rows=51.00 loops=1)
|
||||
Workers Planned: 2
|
||||
Workers Launched: 2
|
||||
Buffers: shared hit=4307
|
||||
-> Sort (cost=5162.85..5163.06 rows=84 width=238) (actual time=12.274..12.277 rows=21.00 loops=3)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 44kB
|
||||
Buffers: shared hit=4307
|
||||
Worker 0: Sort Method: quicksort Memory: 27kB
|
||||
Worker 1: Sort Method: quicksort Memory: 30kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..5160.17 rows=84 width=238) (actual time=5.204..12.212 rows=25.00 loops=3)
|
||||
Filter: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Rows Removed by Filter: 40348
|
||||
Buffers: shared hit=4277
|
||||
Planning:
|
||||
Buffers: shared hit=85
|
||||
Planning Time: 0.565 ms
|
||||
Execution Time: 27.653 ms
|
||||
@@ -0,0 +1,20 @@
|
||||
Limit (cost=6162.88..6165.20 rows=20 width=238) (actual time=12.515..16.342 rows=1.00 loops=1)
|
||||
Buffers: shared hit=4307
|
||||
-> Gather Merge (cost=6162.88..6186.40 rows=202 width=238) (actual time=12.513..16.339 rows=1.00 loops=1)
|
||||
Workers Planned: 2
|
||||
Workers Launched: 2
|
||||
Buffers: shared hit=4307
|
||||
-> Sort (cost=5162.85..5163.06 rows=84 width=238) (actual time=8.455..8.456 rows=0.33 loops=3)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
Buffers: shared hit=4307
|
||||
Worker 0: Sort Method: quicksort Memory: 25kB
|
||||
Worker 1: Sort Method: quicksort Memory: 25kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..5160.17 rows=84 width=238) (actual time=7.451..8.415 rows=0.33 loops=3)
|
||||
Filter: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))
|
||||
Rows Removed by Filter: 40373
|
||||
Buffers: shared hit=4277
|
||||
Planning:
|
||||
Buffers: shared hit=85
|
||||
Planning Time: 0.289 ms
|
||||
Execution Time: 16.395 ms
|
||||
Reference in New Issue
Block a user