forked from mtusi2026/mtusi2026lab2
ЛР2: PostgreSQL, сессии Bearer, кэш Valkey, Compose, исследование индексов и backup
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
$ python3 tests/smoke.py
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
$ python3 tests/resilience.py --mode persistence --action-script scripts/restart.sh (Windows: restart.cmd; контейнеры до/после — persistence_containers.txt)
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
$ python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
$ python -m unittest discover -s student-tests -p test_api.py
|
||||
Ran 12 tests in 2.802s
|
||||
OK
|
||||
$ python student-tests/test_expiry.py (SESSION_TTL_SECONDS=2)
|
||||
Ran 2 tests in 10.310s
|
||||
OK
|
||||
$ python student-tests/test_dependencies.py (остановка Valkey / PostgreSQL)
|
||||
Ran 2 tests in 14.884s
|
||||
OK
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 2,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 20.0,
|
||||
"elapsed_seconds": 20.187,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 19411,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 961.559,
|
||||
"successful_latency_ms": {
|
||||
"p50": 15.0,
|
||||
"p95": 16.0,
|
||||
"p99": 16.0
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# 1. миграции на пустую БД
|
||||
{"ts": "2026-10-02T22:28:31Z", "level": "info", "msg": "migration_applied", "version": "0001_init.sql"}
|
||||
{"ts": "2026-10-02T22:28:31Z", "level": "info", "msg": "migrations_done", "applied": 1, "total": 1}
|
||||
# 2. повторный запуск (идемпотентность)
|
||||
{"ts": "2026-10-02T22:28:32Z", "level": "info", "msg": "migrations_done", "applied": 0, "total": 1}
|
||||
# 3. запуск на рабочей БД (уже применено)
|
||||
{"ts": "2026-10-02T22:28:34Z", "level": "info", "msg": "migrations_done", "applied": 0, "total": 1}
|
||||
@@ -0,0 +1,18 @@
|
||||
# До перезапуска
|
||||
/mtusi-lab2-postgres-1 StartedAt=2026-10-02T22:27:01.751292444Z restarts=0 health=healthy
|
||||
/mtusi-lab2-valkey-1 StartedAt=2026-10-02T22:27:04.038032167Z restarts=0 health=healthy
|
||||
/mtusi-lab2-api-1 StartedAt=2026-10-02T22:26:48.094412012Z restarts=0 health=healthy
|
||||
# docker volume ls (должны сохраниться)
|
||||
mtusi-lab2_pgdata
|
||||
mtusi-lab2_valkeydata
|
||||
|
||||
$ python3 tests/resilience.py --mode persistence --action-script scripts/restart.sh (на Windows: scripts/restart.cmd, тот же compose restart)
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
# После перезапуска (StartedAt всех трёх сервисов изменился, volumes на месте)
|
||||
/mtusi-lab2-postgres-1 StartedAt=2026-10-02T22:27:28.059336695Z restarts=0 health=starting
|
||||
/mtusi-lab2-valkey-1 StartedAt=2026-10-02T22:27:28.233209818Z restarts=0 health=starting
|
||||
/mtusi-lab2-api-1 StartedAt=2026-10-02T22:27:28.462473382Z restarts=0 health=starting
|
||||
mtusi-lab2_pgdata
|
||||
mtusi-lab2_valkeydata
|
||||
@@ -0,0 +1,307 @@
|
||||
===== V0_pk_only / keyset_big_chat_middle (медиана 10.195 мс из 9) =====
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=5036.29..5036.42 rows=51 width=171) (actual time=10.450..10.456 rows=51 loops=1)
|
||||
Buffers: shared hit=2632
|
||||
-> Sort (cost=5036.29..5079.22 rows=17169 width=171) (actual time=10.448..10.451 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 40kB
|
||||
Buffers: shared hit=2632
|
||||
-> Seq Scan on messages (cost=0.00..4463.50 rows=17169 width=171) (actual time=0.080..8.640 rows=29999 loops=1)
|
||||
Filter: ((chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 06:45:15.998444+00'::timestamp with time zone, '7df96ec6-9cae-4a9d-9696-c854f9218ab5'::uuid)))
|
||||
Rows Removed by Filter: 75001
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=113
|
||||
Planning Time: 0.456 ms
|
||||
Execution Time: 10.519 ms
|
||||
(14 rows)
|
||||
|
||||
===== V0_pk_only / first_page_big_chat (медиана 9.149 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=5585.66..5591.53 rows=51 width=171) (actual time=7.011..8.604 rows=51 loops=1)
|
||||
Buffers: shared hit=2670
|
||||
-> Gather Merge (cost=5585.66..9679.32 rows=35597 width=171) (actual time=7.009..8.600 rows=51 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=2670
|
||||
-> Sort (cost=4585.65..4674.64 rows=35597 width=171) (actual time=5.790..5.792 rows=51 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 40kB
|
||||
Buffers: shared hit=2670
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 39kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..3398.06 rows=35597 width=171) (actual time=0.007..3.950 rows=30000 loops=2)
|
||||
Filter: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Rows Removed by Filter: 22500
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=114
|
||||
Planning Time: 0.435 ms
|
||||
Execution Time: 8.655 ms
|
||||
(19 rows)
|
||||
|
||||
===== V0_pk_only / offset_big_chat_30000 (медиана 23.898 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=13584.11..13589.97 rows=51 width=171) (actual time=20.720..23.072 rows=51 loops=1)
|
||||
Buffers: shared hit=2670, temp read=1088 written=1370
|
||||
-> Gather Merge (cost=10134.11..14227.76 rows=35597 width=171) (actual time=15.085..22.454 rows=30051 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=2670, temp read=1088 written=1370
|
||||
-> Sort (cost=9134.10..9223.09 rows=35597 width=171) (actual time=13.549..14.977 rows=15192 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: external merge Disk: 5800kB
|
||||
Buffers: shared hit=2670, temp read=1088 written=1370
|
||||
Worker 0: Sort Method: external merge Disk: 5128kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..3398.06 rows=35597 width=171) (actual time=0.006..4.295 rows=30000 loops=2)
|
||||
Filter: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Rows Removed by Filter: 22500
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=114
|
||||
Planning Time: 0.422 ms
|
||||
Execution Time: 23.755 ms
|
||||
(19 rows)
|
||||
|
||||
===== V0_pk_only / first_page_small_chat (медиана 5.785 мс из 9) =====
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=3938.69..3938.72 rows=11 width=171) (actual time=5.746..5.749 rows=10 loops=1)
|
||||
Buffers: shared hit=2632
|
||||
-> Sort (cost=3938.69..3938.72 rows=11 width=171) (actual time=5.745..5.746 rows=10 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
Buffers: shared hit=2632
|
||||
-> Seq Scan on messages (cost=0.00..3938.50 rows=11 width=171) (actual time=5.401..5.713 rows=10 loops=1)
|
||||
Filter: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Rows Removed by Filter: 104990
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=114
|
||||
Planning Time: 0.440 ms
|
||||
Execution Time: 5.777 ms
|
||||
(14 rows)
|
||||
|
||||
===== V1_chat_id / keyset_big_chat_middle (медиана 8.189 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=4916.20..4916.32 rows=51 width=171) (actual time=8.528..8.535 rows=51 loops=1)
|
||||
Buffers: shared hit=1567
|
||||
-> Sort (cost=4916.20..4958.68 rows=16994 width=171) (actual time=8.526..8.530 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 40kB
|
||||
Buffers: shared hit=1567
|
||||
-> Bitmap Heap Scan on messages (cost=674.15..4349.24 rows=16994 width=171) (actual time=1.094..6.629 rows=29999 loops=1)
|
||||
Recheck Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Filter: (ROW(created_at, id) > ROW('2026-10-02 06:45:15.998444+00'::timestamp with time zone, '7df96ec6-9cae-4a9d-9696-c854f9218ab5'::uuid))
|
||||
Rows Removed by Filter: 30001
|
||||
Heap Blocks: exact=1508
|
||||
Buffers: shared hit=1561
|
||||
-> Bitmap Index Scan on ix_chat (cost=0.00..669.90 rows=59948 width=0) (actual time=0.923..0.923 rows=60000 loops=1)
|
||||
Index Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Buffers: shared hit=53
|
||||
Planning:
|
||||
Buffers: shared hit=125
|
||||
Planning Time: 0.555 ms
|
||||
Execution Time: 8.615 ms
|
||||
(19 rows)
|
||||
|
||||
===== V1_chat_id / first_page_big_chat (медиана 8.781 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=5574.55..5580.42 rows=51 width=171) (actual time=7.829..10.288 rows=51 loops=1)
|
||||
Buffers: shared hit=2670
|
||||
-> Gather Merge (cost=5574.55..9629.91 rows=35264 width=171) (actual time=7.827..10.282 rows=51 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=2670
|
||||
-> Sort (cost=4574.54..4662.70 rows=35264 width=171) (actual time=6.300..6.303 rows=51 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 40kB
|
||||
Buffers: shared hit=2670
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 39kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..3398.06 rows=35264 width=171) (actual time=0.007..4.247 rows=30000 loops=2)
|
||||
Filter: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Rows Removed by Filter: 22500
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=126
|
||||
Planning Time: 0.622 ms
|
||||
Execution Time: 10.363 ms
|
||||
(19 rows)
|
||||
|
||||
===== V1_chat_id / offset_big_chat_30000 (медиана 22.723 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=13525.04..13530.91 rows=51 width=171) (actual time=19.289..21.512 rows=51 loops=1)
|
||||
Buffers: shared hit=2670, temp read=1089 written=1371
|
||||
-> Gather Merge (cost=10075.04..14130.40 rows=35264 width=171) (actual time=13.620..20.895 rows=30051 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=2670, temp read=1089 written=1371
|
||||
-> Sort (cost=9075.03..9163.19 rows=35264 width=171) (actual time=11.849..13.263 rows=15164 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: external merge Disk: 5976kB
|
||||
Buffers: shared hit=2670, temp read=1089 written=1371
|
||||
Worker 0: Sort Method: external merge Disk: 4960kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..3398.06 rows=35264 width=171) (actual time=0.006..3.514 rows=30000 loops=2)
|
||||
Filter: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Rows Removed by Filter: 22500
|
||||
Buffers: shared hit=2626
|
||||
Planning:
|
||||
Buffers: shared hit=126
|
||||
Planning Time: 0.514 ms
|
||||
Execution Time: 22.164 ms
|
||||
(19 rows)
|
||||
|
||||
===== V1_chat_id / first_page_small_chat (медиана 0.063 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=46.57..46.60 rows=11 width=171) (actual time=0.039..0.040 rows=10 loops=1)
|
||||
Buffers: shared hit=9
|
||||
-> Sort (cost=46.57..46.60 rows=11 width=171) (actual time=0.038..0.039 rows=10 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
Buffers: shared hit=9
|
||||
-> Bitmap Heap Scan on messages (cost=4.38..46.38 rows=11 width=171) (actual time=0.012..0.012 rows=10 loops=1)
|
||||
Recheck Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Heap Blocks: exact=1
|
||||
Buffers: shared hit=3
|
||||
-> Bitmap Index Scan on ix_chat (cost=0.00..4.38 rows=11 width=0) (actual time=0.007..0.007 rows=10 loops=1)
|
||||
Index Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Buffers: shared hit=2
|
||||
Planning:
|
||||
Buffers: shared hit=126
|
||||
Planning Time: 0.475 ms
|
||||
Execution Time: 0.063 ms
|
||||
(17 rows)
|
||||
|
||||
===== V2_chat_created_id / keyset_big_chat_middle (медиана 0.076 мс из 9) =====
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..34.02 rows=51 width=171) (actual time=0.022..0.033 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using ix_hist on messages (cost=0.42..11340.82 rows=17213 width=171) (actual time=0.021..0.030 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 06:45:15.998444+00'::timestamp with time zone, '7df96ec6-9cae-4a9d-9696-c854f9218ab5'::uuid)))
|
||||
Buffers: shared hit=6
|
||||
Planning:
|
||||
Buffers: shared hit=136
|
||||
Planning Time: 0.608 ms
|
||||
Execution Time: 0.067 ms
|
||||
(9 rows)
|
||||
|
||||
===== V2_chat_created_id / first_page_big_chat (медиана 0.043 мс из 9) =====
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..11.65 rows=51 width=171) (actual time=0.013..0.021 rows=51 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using ix_hist on messages (cost=0.42..13298.21 rows=60389 width=171) (actual time=0.012..0.018 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Buffers: shared hit=5
|
||||
Planning:
|
||||
Buffers: shared hit=137
|
||||
Planning Time: 0.516 ms
|
||||
Execution Time: 0.038 ms
|
||||
(9 rows)
|
||||
|
||||
===== V2_chat_created_id / offset_big_chat_30000 (медиана 3.492 мс из 9) =====
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=6606.48..6617.71 rows=51 width=171) (actual time=3.347..3.355 rows=51 loops=1)
|
||||
Buffers: shared hit=1234
|
||||
-> Index Scan using ix_hist on messages (cost=0.42..13298.21 rows=60389 width=171) (actual time=0.016..2.753 rows=30051 loops=1)
|
||||
Index Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Buffers: shared hit=1234
|
||||
Planning:
|
||||
Buffers: shared hit=137
|
||||
Planning Time: 0.556 ms
|
||||
Execution Time: 3.378 ms
|
||||
(9 rows)
|
||||
|
||||
===== V2_chat_created_id / first_page_small_chat (медиана 0.07 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=46.69..46.72 rows=11 width=171) (actual time=0.057..0.058 rows=10 loops=1)
|
||||
Buffers: shared hit=10
|
||||
-> Sort (cost=46.69..46.72 rows=11 width=171) (actual time=0.055..0.056 rows=10 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
Buffers: shared hit=10
|
||||
-> Bitmap Heap Scan on messages (cost=4.50..46.50 rows=11 width=171) (actual time=0.023..0.023 rows=10 loops=1)
|
||||
Recheck Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Heap Blocks: exact=1
|
||||
Buffers: shared hit=4
|
||||
-> Bitmap Index Scan on ix_hist (cost=0.00..4.50 rows=11 width=0) (actual time=0.013..0.013 rows=10 loops=1)
|
||||
Index Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=137
|
||||
Planning Time: 0.785 ms
|
||||
Execution Time: 0.090 ms
|
||||
(17 rows)
|
||||
|
||||
===== V3_chat_created_id_include / keyset_big_chat_middle (медиана 0.068 мс из 9) =====
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..34.11 rows=51 width=171) (actual time=0.026..0.033 rows=51 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using ix_hist_inc on messages (cost=0.42..11506.55 rows=17419 width=171) (actual time=0.025..0.029 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 06:45:15.998444+00'::timestamp with time zone, '7df96ec6-9cae-4a9d-9696-c854f9218ab5'::uuid)))
|
||||
Buffers: shared hit=5
|
||||
Planning:
|
||||
Buffers: shared hit=139
|
||||
Planning Time: 0.586 ms
|
||||
Execution Time: 0.095 ms
|
||||
(9 rows)
|
||||
|
||||
===== V3_chat_created_id_include / first_page_big_chat (медиана 0.042 мс из 9) =====
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..12.14 rows=51 width=171) (actual time=0.013..0.024 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using ix_hist_inc on messages (cost=0.42..13823.52 rows=60154 width=171) (actual time=0.013..0.021 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Buffers: shared hit=6
|
||||
Planning:
|
||||
Buffers: shared hit=140
|
||||
Planning Time: 0.581 ms
|
||||
Execution Time: 0.052 ms
|
||||
(9 rows)
|
||||
|
||||
===== V3_chat_created_id_include / offset_big_chat_30000 (медиана 3.587 мс из 9) =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=6894.28..6906.00 rows=51 width=171) (actual time=3.503..3.509 rows=51 loops=1)
|
||||
Buffers: shared hit=1300
|
||||
-> Index Scan using ix_hist_inc on messages (cost=0.42..13823.52 rows=60154 width=171) (actual time=0.011..2.892 rows=30051 loops=1)
|
||||
Index Cond: (chat_id = 'ae663d40-43bf-4930-94b0-07eef693fca2'::uuid)
|
||||
Buffers: shared hit=1300
|
||||
Planning:
|
||||
Buffers: shared hit=140
|
||||
Planning Time: 0.513 ms
|
||||
Execution Time: 3.529 ms
|
||||
(9 rows)
|
||||
|
||||
===== V3_chat_created_id_include / first_page_small_chat (медиана 0.075 мс из 9) =====
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=42.93..42.96 rows=10 width=171) (actual time=0.064..0.066 rows=10 loops=1)
|
||||
Buffers: shared hit=10
|
||||
-> Sort (cost=42.93..42.96 rows=10 width=171) (actual time=0.063..0.064 rows=10 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
Buffers: shared hit=10
|
||||
-> Bitmap Heap Scan on messages (cost=4.50..42.77 rows=10 width=171) (actual time=0.023..0.024 rows=10 loops=1)
|
||||
Recheck Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Heap Blocks: exact=1
|
||||
Buffers: shared hit=4
|
||||
-> Bitmap Index Scan on ix_hist_inc (cost=0.00..4.49 rows=10 width=0) (actual time=0.014..0.014 rows=10 loops=1)
|
||||
Index Cond: (chat_id = 'b8b701bf-339f-44c0-9468-9e10800583fe'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=140
|
||||
Planning Time: 0.564 ms
|
||||
Execution Time: 0.112 ms
|
||||
(17 rows)
|
||||
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"date": "2026-10-03 01:25:18",
|
||||
"messages": 105000,
|
||||
"postgres": "17.11",
|
||||
"chat_sizes": "1x60000, 5x5000, 100x100, 1000x10",
|
||||
"variants": {
|
||||
"V0_pk_only": {
|
||||
"queries": {
|
||||
"keyset_big_chat_middle": {
|
||||
"median_ms": 10.195,
|
||||
"min_ms": 9.989,
|
||||
"top_node": "Sort"
|
||||
},
|
||||
"first_page_big_chat": {
|
||||
"median_ms": 9.149,
|
||||
"min_ms": 8.655,
|
||||
"top_node": "Gather Merge"
|
||||
},
|
||||
"offset_big_chat_30000": {
|
||||
"median_ms": 23.898,
|
||||
"min_ms": 22.635,
|
||||
"top_node": "Gather Merge"
|
||||
},
|
||||
"first_page_small_chat": {
|
||||
"median_ms": 5.785,
|
||||
"min_ms": 5.575,
|
||||
"top_node": "Sort"
|
||||
}
|
||||
},
|
||||
"bulk_insert_all_rows_seconds": 0.42,
|
||||
"single_insert_5000_seconds": 0.030014,
|
||||
"table_and_index_size": "21 MB / indexes 4336 kB"
|
||||
},
|
||||
"V1_chat_id": {
|
||||
"queries": {
|
||||
"keyset_big_chat_middle": {
|
||||
"median_ms": 8.189,
|
||||
"min_ms": 8.031,
|
||||
"top_node": "Sort"
|
||||
},
|
||||
"first_page_big_chat": {
|
||||
"median_ms": 8.781,
|
||||
"min_ms": 8.102,
|
||||
"top_node": "Gather Merge"
|
||||
},
|
||||
"offset_big_chat_30000": {
|
||||
"median_ms": 22.723,
|
||||
"min_ms": 22.164,
|
||||
"top_node": "Gather Merge"
|
||||
},
|
||||
"first_page_small_chat": {
|
||||
"median_ms": 0.063,
|
||||
"min_ms": 0.062,
|
||||
"top_node": "Sort"
|
||||
}
|
||||
},
|
||||
"bulk_insert_all_rows_seconds": 0.49,
|
||||
"single_insert_5000_seconds": 0.034086,
|
||||
"table_and_index_size": "21 MB / indexes 5168 kB"
|
||||
},
|
||||
"V2_chat_created_id": {
|
||||
"queries": {
|
||||
"keyset_big_chat_middle": {
|
||||
"median_ms": 0.076,
|
||||
"min_ms": 0.061,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"first_page_big_chat": {
|
||||
"median_ms": 0.043,
|
||||
"min_ms": 0.036,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"offset_big_chat_30000": {
|
||||
"median_ms": 3.492,
|
||||
"min_ms": 3.378,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"first_page_small_chat": {
|
||||
"median_ms": 0.07,
|
||||
"min_ms": 0.068,
|
||||
"top_node": "Sort"
|
||||
}
|
||||
},
|
||||
"bulk_insert_all_rows_seconds": 0.53,
|
||||
"single_insert_5000_seconds": 0.037934,
|
||||
"table_and_index_size": "21 MB / indexes 12 MB"
|
||||
},
|
||||
"V3_chat_created_id_include": {
|
||||
"queries": {
|
||||
"keyset_big_chat_middle": {
|
||||
"median_ms": 0.068,
|
||||
"min_ms": 0.059,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"first_page_big_chat": {
|
||||
"median_ms": 0.042,
|
||||
"min_ms": 0.039,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"offset_big_chat_30000": {
|
||||
"median_ms": 3.587,
|
||||
"min_ms": 3.453,
|
||||
"top_node": "Index Scan"
|
||||
},
|
||||
"first_page_small_chat": {
|
||||
"median_ms": 0.075,
|
||||
"min_ms": 0.068,
|
||||
"top_node": "Sort"
|
||||
}
|
||||
},
|
||||
"bulk_insert_all_rows_seconds": 0.5,
|
||||
"single_insert_5000_seconds": 0.0378,
|
||||
"table_and_index_size": "21 MB / indexes 15 MB"
|
||||
}
|
||||
},
|
||||
"backup_restore": {
|
||||
"backup_seconds": 1.15,
|
||||
"dump_bytes": 7765134,
|
||||
"restore_seconds": 0.85,
|
||||
"source_before_backup": {
|
||||
"messages_checksum": "105000 105f3be9c5800d9063d35984fce8cdc5",
|
||||
"rows": "users=200 chats=1106 members=1106"
|
||||
},
|
||||
"source_after_extra_writes": "105025 6b8ca4bbec223dfe62280f33554e2247",
|
||||
"restored": {
|
||||
"messages_checksum": "105000 105f3be9c5800d9063d35984fce8cdc5",
|
||||
"rows": "users=200 chats=1106 members=1106"
|
||||
},
|
||||
"restore_matches_backup_state": true,
|
||||
"page_checksum_source": "45def68fe4148adfc2d9066720956ab4",
|
||||
"page_checksum_restored": "45def68fe4148adfc2d9066720956ab4",
|
||||
"sample_page_matches": true,
|
||||
"extra_rows_written_after_backup_absent_in_restore": true,
|
||||
"restored_indexes": "ix_hist,messages_pkey"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user