docs(evidence): add index comparison, write cost and restore verification
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# Backup → Restore → сверка
|
||||
# date: 2026-10-02T16:46:16Z
|
||||
|
||||
## Снимок источника
|
||||
users=52
|
||||
chats=37
|
||||
messages=110222
|
||||
sessions=0
|
||||
md5 первых 1000 сообщений: f3c9c53ed0fd56da19a01f213d0ff2f0
|
||||
|
||||
## pg_dump -Fc
|
||||
файл: /mnt/c/Users/Антон/Desktop/4_курс/mtusi2026lab2-fork/evidence/dump_20261002_194616.dump
|
||||
размер: 3.4M
|
||||
время дампа: 1s
|
||||
|
||||
## Поднимаем целевой контейнер pg_restore_target на :5433
|
||||
Ждём готовности...
|
||||
## pg_restore
|
||||
время восстановления: 0s
|
||||
|
||||
## Снимок цели
|
||||
users=52
|
||||
chats=37
|
||||
messages=110222
|
||||
sessions=0
|
||||
md5 первых 1000 сообщений: f3c9c53ed0fd56da19a01f213d0ff2f0
|
||||
|
||||
## Сверка
|
||||
PASS: счётчики совпадают
|
||||
PASS: контрольные суммы совпадают
|
||||
|
||||
## Индексы в восстановленной БД
|
||||
indexname | size
|
||||
------------------------------+---------
|
||||
messages_chat_created_id_idx | 6360 kB
|
||||
messages_pkey | 3424 kB
|
||||
(2 rows)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# Сравнение индексов: keyset-пагинация, chat_id=349f1aef-3bbc-42d1-8724-e8d22b8c2253
|
||||
# date: 2026-10-02T16:45:25Z
|
||||
|
||||
## A. Baseline (chat_id, created_at, id)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..7.31 rows=50 width=69) (actual time=0.029..0.046 rows=50 loops=1)
|
||||
Buffers: shared hit=42 read=3
|
||||
-> Index Scan using messages_chat_created_id_idx on messages (cost=0.42..7619.95 rows=55273 width=69) (actual time=0.028..0.042 rows=50 loops=1)
|
||||
Index Cond: (chat_id = '349f1aef-3bbc-42d1-8724-e8d22b8c2253'::uuid)
|
||||
Buffers: shared hit=42 read=3
|
||||
Planning:
|
||||
Buffers: shared hit=106 read=1
|
||||
Planning Time: 0.664 ms
|
||||
Execution Time: 0.070 ms
|
||||
(9 rows)
|
||||
|
||||
|
||||
## B1. Covering (chat_id, created_at, id) INCLUDE (sender_id)
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..7.77 rows=50 width=69) (actual time=0.027..0.048 rows=50 loops=1)
|
||||
Buffers: shared hit=42 read=4
|
||||
-> Index Scan using messages_covering_small on messages (cost=0.42..8096.41 rows=55056 width=69) (actual time=0.026..0.044 rows=50 loops=1)
|
||||
Index Cond: (chat_id = '349f1aef-3bbc-42d1-8724-e8d22b8c2253'::uuid)
|
||||
Buffers: shared hit=42 read=4
|
||||
Planning:
|
||||
Buffers: shared hit=111 read=1
|
||||
Planning Time: 0.639 ms
|
||||
Execution Time: 0.070 ms
|
||||
(9 rows)
|
||||
|
||||
|
||||
## B2. Covering (chat_id, created_at, id) INCLUDE (sender_id, text)
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..4.40 rows=50 width=69) (actual time=0.038..0.044 rows=50 loops=1)
|
||||
Buffers: shared hit=1 read=3
|
||||
-> Index Only Scan using messages_covering_full on messages (cost=0.42..4393.54 rows=55144 width=69) (actual time=0.037..0.041 rows=50 loops=1)
|
||||
Index Cond: (chat_id = '349f1aef-3bbc-42d1-8724-e8d22b8c2253'::uuid)
|
||||
Heap Fetches: 0
|
||||
Buffers: shared hit=1 read=3
|
||||
Planning:
|
||||
Buffers: shared hit=112 read=1
|
||||
Planning Time: 0.717 ms
|
||||
Execution Time: 0.071 ms
|
||||
(10 rows)
|
||||
|
||||
|
||||
## C. Без индекса (Seq Scan)
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=4314.02..4319.77 rows=50 width=69) (actual time=7.709..9.590 rows=50 loops=1)
|
||||
Buffers: shared hit=1486
|
||||
-> Gather Merge (cost=4314.02..7988.96 rows=31956 width=69) (actual time=7.707..9.585 rows=50 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=1486
|
||||
-> Sort (cost=3314.01..3393.90 rows=31956 width=69) (actual time=5.760..5.763 rows=50 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 32kB
|
||||
Buffers: shared hit=1486
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 32kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..2252.46 rows=31956 width=69) (actual time=0.009..3.673 rows=27500 loops=2)
|
||||
Filter: (chat_id = '349f1aef-3bbc-42d1-8724-e8d22b8c2253'::uuid)
|
||||
Rows Removed by Filter: 27611
|
||||
Buffers: shared hit=1442
|
||||
Planning:
|
||||
Buffers: shared hit=84
|
||||
Planning Time: 0.598 ms
|
||||
Execution Time: 9.660 ms
|
||||
(19 rows)
|
||||
|
||||
|
||||
## Восстанавливаем baseline
|
||||
indexname | size
|
||||
------------------------------+---------
|
||||
messages_chat_created_id_idx | 6360 kB
|
||||
messages_pkey | 4568 kB
|
||||
(2 rows)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# Стоимость записи: 5000 INSERT в один чат
|
||||
# date: 2026-10-02T16:45:29Z
|
||||
# chat_id: 349f1aef-3bbc-42d1-8724-e8d22b8c2253
|
||||
|
||||
## A. Baseline (chat_id, created_at, id)
|
||||
## INSERT 5000 rows
|
||||
Timing is on.
|
||||
DO
|
||||
Time: 353.267 ms
|
||||
indexname | size
|
||||
------------------------------+---------
|
||||
messages_chat_created_id_idx | 6768 kB
|
||||
messages_pkey | 4736 kB
|
||||
(2 rows)
|
||||
|
||||
|
||||
|
||||
## B. Covering (chat_id, created_at, id) INCLUDE (sender_id)
|
||||
## INSERT 5000 rows
|
||||
Timing is on.
|
||||
DO
|
||||
Time: 288.259 ms
|
||||
indexname | size
|
||||
-------------------------+---------
|
||||
messages_covering_small | 8848 kB
|
||||
messages_pkey | 4944 kB
|
||||
(2 rows)
|
||||
|
||||
|
||||
|
||||
## Восстанавливаем baseline
|
||||
Reference in New Issue
Block a user