Исследование трека 2, доказательства и отчёт

This commit is contained in:
Pavel Grigorev
2026-10-30 16:43:07 +03:00
parent 0e5b76e558
commit c8d078390c
19 changed files with 2126 additions and 15 deletions
@@ -0,0 +1,29 @@
{
"big_d50_offset": {
"median_ms": 11.508,
"p95_ms": 12.992,
"planning_ms": 0.061,
"shared_hit": 8064,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d90_offset": {
"median_ms": 21.338,
"p95_ms": 21.923,
"planning_ms": 0.074,
"shared_hit": 14567,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"medium_d90_offset": {
"median_ms": 0.683,
"p95_ms": 0.728,
"planning_ms": 0.042,
"shared_hit": 2499,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
}
}
@@ -0,0 +1,29 @@
{
"big_d50_offset": {
"median_ms": 10.606,
"p95_ms": 11.549,
"planning_ms": 0.06,
"shared_hit": 8064,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d90_offset": {
"median_ms": 120.438,
"p95_ms": 127.612,
"planning_ms": 0.085,
"shared_hit": 7865,
"shared_read": 4846,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d90_offset": {
"median_ms": 5.041,
"p95_ms": 5.433,
"planning_ms": 0.055,
"shared_hit": 2713,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(messages_chat_history_idx)"
}
}
+578
View File
@@ -0,0 +1,578 @@
{
"environment": {
"date": "2026-10-29T08:55:57Z",
"docker_cpus": 12,
"docker_memory_gib": 1.9,
"docker_server": "27.2.0",
"postgres": "17.11",
"shared_buffers": "128MB"
},
"runs": 15,
"warmup": 3,
"variants": {
"pk_only": {
"build_seconds": 0.0,
"index_bytes": 0,
"queries": {
"big_first": {
"median_ms": 31.636,
"p95_ms": 33.929,
"planning_ms": 0.068,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d50_keyset": {
"median_ms": 29.115,
"p95_ms": 45.68,
"planning_ms": 0.083,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d50_offset": {
"median_ms": 116.405,
"p95_ms": 142.333,
"planning_ms": 0.074,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d90_keyset": {
"median_ms": 25.118,
"p95_ms": 27.994,
"planning_ms": 0.078,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d90_offset": {
"median_ms": 135.534,
"p95_ms": 144.718,
"planning_ms": 0.074,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_first": {
"median_ms": 23.077,
"p95_ms": 23.909,
"planning_ms": 0.068,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d50_keyset": {
"median_ms": 26.5,
"p95_ms": 31.003,
"planning_ms": 0.081,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d50_offset": {
"median_ms": 24.115,
"p95_ms": 26.148,
"planning_ms": 0.069,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d90_keyset": {
"median_ms": 23.375,
"p95_ms": 25.052,
"planning_ms": 0.08,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d90_offset": {
"median_ms": 23.633,
"p95_ms": 24.813,
"planning_ms": 0.067,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_first": {
"median_ms": 20.085,
"p95_ms": 21.647,
"planning_ms": 0.064,
"shared_hit": 12361,
"shared_read": 0,
"rows": 10,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_d50_keyset": {
"median_ms": 22.948,
"p95_ms": 25.171,
"planning_ms": 0.08,
"shared_hit": 12273,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Sort > Gather > Seq Scan"
},
"small_d50_offset": {
"median_ms": 21.521,
"p95_ms": 23.739,
"planning_ms": 0.066,
"shared_hit": 12361,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_d90_keyset": {
"median_ms": 22.477,
"p95_ms": 25.176,
"planning_ms": 0.081,
"shared_hit": 12273,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Sort > Gather > Seq Scan"
},
"small_d90_offset": {
"median_ms": 22.451,
"p95_ms": 24.216,
"planning_ms": 0.068,
"shared_hit": 12361,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
}
}
},
"chat_id": {
"build_seconds": 0.43,
"index_bytes": 1572864,
"queries": {
"big_first": {
"median_ms": 29.135,
"p95_ms": 34.976,
"planning_ms": 0.077,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d50_keyset": {
"median_ms": 28.754,
"p95_ms": 30.474,
"planning_ms": 0.093,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d50_offset": {
"median_ms": 114.655,
"p95_ms": 118.28,
"planning_ms": 0.081,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d90_keyset": {
"median_ms": 25.87,
"p95_ms": 28.291,
"planning_ms": 0.088,
"shared_hit": 12303,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"big_d90_offset": {
"median_ms": 130.247,
"p95_ms": 139.705,
"planning_ms": 0.086,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_first": {
"median_ms": 3.504,
"p95_ms": 3.65,
"planning_ms": 0.058,
"shared_hit": 2695,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(bench_chat_idx)"
},
"medium_d50_keyset": {
"median_ms": 3.528,
"p95_ms": 4.512,
"planning_ms": 0.073,
"shared_hit": 2695,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(bench_chat_idx)"
},
"medium_d50_offset": {
"median_ms": 6.258,
"p95_ms": 6.974,
"planning_ms": 0.071,
"shared_hit": 2695,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(bench_chat_idx)"
},
"medium_d90_keyset": {
"median_ms": 3.442,
"p95_ms": 4.265,
"planning_ms": 0.076,
"shared_hit": 2695,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(bench_chat_idx)"
},
"medium_d90_offset": {
"median_ms": 6.063,
"p95_ms": 6.213,
"planning_ms": 0.061,
"shared_hit": 2695,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(bench_chat_idx)"
},
"small_first": {
"median_ms": 0.061,
"p95_ms": 0.064,
"planning_ms": 0.041,
"shared_hit": 13,
"shared_read": 0,
"rows": 10,
"plan": "Limit > Sort > Index Scan(bench_chat_idx)"
},
"small_d50_keyset": {
"median_ms": 0.064,
"p95_ms": 0.098,
"planning_ms": 0.05,
"shared_hit": 13,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Sort > Index Scan(bench_chat_idx)"
},
"small_d50_offset": {
"median_ms": 0.079,
"p95_ms": 0.1,
"planning_ms": 0.044,
"shared_hit": 13,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Sort > Index Scan(bench_chat_idx)"
},
"small_d90_keyset": {
"median_ms": 0.067,
"p95_ms": 0.108,
"planning_ms": 0.05,
"shared_hit": 13,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Sort > Index Scan(bench_chat_idx)"
},
"small_d90_offset": {
"median_ms": 0.087,
"p95_ms": 0.116,
"planning_ms": 0.055,
"shared_hit": 13,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Sort > Index Scan(bench_chat_idx)"
}
}
},
"created_at_id": {
"build_seconds": 0.48,
"index_bytes": 8126464,
"queries": {
"big_first": {
"median_ms": 0.055,
"p95_ms": 0.078,
"planning_ms": 0.026,
"shared_hit": 9,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"big_d50_keyset": {
"median_ms": 0.056,
"p95_ms": 0.063,
"planning_ms": 0.05,
"shared_hit": 18,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"big_d50_offset": {
"median_ms": 22.942,
"p95_ms": 23.121,
"planning_ms": 0.053,
"shared_hit": 9806,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"big_d90_keyset": {
"median_ms": 0.057,
"p95_ms": 0.077,
"planning_ms": 0.053,
"shared_hit": 17,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"big_d90_offset": {
"median_ms": 41.109,
"p95_ms": 41.439,
"planning_ms": 0.064,
"shared_hit": 17650,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"medium_first": {
"median_ms": 0.349,
"p95_ms": 0.378,
"planning_ms": 0.025,
"shared_hit": 327,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"medium_d50_keyset": {
"median_ms": 0.419,
"p95_ms": 0.49,
"planning_ms": 0.049,
"shared_hit": 375,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"medium_d50_offset": {
"median_ms": 23.305,
"p95_ms": 24.069,
"planning_ms": 0.074,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_d90_keyset": {
"median_ms": 0.354,
"p95_ms": 0.399,
"planning_ms": 0.05,
"shared_hit": 314,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"medium_d90_offset": {
"median_ms": 23.641,
"p95_ms": 24.668,
"planning_ms": 0.075,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_first": {
"median_ms": 21.749,
"p95_ms": 22.376,
"planning_ms": 0.078,
"shared_hit": 12361,
"shared_read": 0,
"rows": 10,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_d50_keyset": {
"median_ms": 24.374,
"p95_ms": 25.062,
"planning_ms": 0.092,
"shared_hit": 12273,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Sort > Gather > Seq Scan"
},
"small_d50_offset": {
"median_ms": 21.753,
"p95_ms": 22.948,
"planning_ms": 0.078,
"shared_hit": 12361,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"small_d90_keyset": {
"median_ms": 0.824,
"p95_ms": 1.122,
"planning_ms": 0.055,
"shared_hit": 548,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Index Scan(bench_time_idx)"
},
"small_d90_offset": {
"median_ms": 20.675,
"p95_ms": 23.105,
"planning_ms": 0.078,
"shared_hit": 12361,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
}
}
},
"chat_created_id": {
"build_seconds": 0.53,
"index_bytes": 11796480,
"queries": {
"big_first": {
"median_ms": 0.057,
"p95_ms": 0.07,
"planning_ms": 0.049,
"shared_hit": 9,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d50_keyset": {
"median_ms": 0.048,
"p95_ms": 0.076,
"planning_ms": 0.054,
"shared_hit": 13,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d50_offset": {
"median_ms": 11.673,
"p95_ms": 12.276,
"planning_ms": 0.061,
"shared_hit": 8064,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d90_keyset": {
"median_ms": 0.054,
"p95_ms": 0.073,
"planning_ms": 0.053,
"shared_hit": 11,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"big_d90_offset": {
"median_ms": 132.109,
"p95_ms": 137.947,
"planning_ms": 0.085,
"shared_hit": 12361,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Gather Merge > Sort > Seq Scan"
},
"medium_first": {
"median_ms": 0.051,
"p95_ms": 0.072,
"planning_ms": 0.041,
"shared_hit": 50,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"medium_d50_keyset": {
"median_ms": 0.056,
"p95_ms": 0.093,
"planning_ms": 0.052,
"shared_hit": 48,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"medium_d50_offset": {
"median_ms": 0.43,
"p95_ms": 0.472,
"planning_ms": 0.04,
"shared_hit": 1408,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"medium_d90_keyset": {
"median_ms": 0.057,
"p95_ms": 0.085,
"planning_ms": 0.05,
"shared_hit": 49,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"medium_d90_offset": {
"median_ms": 5.539,
"p95_ms": 6.149,
"planning_ms": 0.058,
"shared_hit": 2713,
"shared_read": 0,
"rows": 51,
"plan": "Limit > Sort > Bitmap Heap Scan > Bitmap Index Scan(messages_chat_history_idx)"
},
"small_first": {
"median_ms": 0.039,
"p95_ms": 0.059,
"planning_ms": 0.039,
"shared_hit": 13,
"shared_read": 0,
"rows": 10,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"small_d50_keyset": {
"median_ms": 0.05,
"p95_ms": 0.069,
"planning_ms": 0.065,
"shared_hit": 8,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"small_d50_offset": {
"median_ms": 0.038,
"p95_ms": 0.049,
"planning_ms": 0.041,
"shared_hit": 13,
"shared_read": 0,
"rows": 5,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"small_d90_keyset": {
"median_ms": 0.038,
"p95_ms": 0.069,
"planning_ms": 0.054,
"shared_hit": 4,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
},
"small_d90_offset": {
"median_ms": 0.046,
"p95_ms": 0.073,
"planning_ms": 0.054,
"shared_hit": 13,
"shared_read": 0,
"rows": 1,
"plan": "Limit > Index Scan(messages_chat_history_idx)"
}
}
}
}
}
+52
View File
@@ -0,0 +1,52 @@
{
"environment": {
"date": "2026-10-29T09:19:01Z",
"docker_cpus": 12,
"docker_memory_gib": 1.9,
"docker_server": "27.2.0",
"postgres": "17.11",
"shared_buffers": "128MB"
},
"dump_bytes": 14099013,
"times_seconds": {
"dump_bench": 1.69,
"dump_messenger": 0.51,
"copy": 1.52,
"restore_bench": 2.36,
"restore_messenger": 0.42,
"analyze": 0.74,
"api_restore_ready": 6.74
},
"rto_seconds": 13.98,
"source": {
"users": "1000",
"chats": "4021",
"chat_members": "8600",
"messages": "200000",
"all_messages_md5": "f3e491b7ebfb52972c8ee73470a90926",
"big_first_page_md5": "516a32c3f0dce2566e84161528ea595c",
"big_d90_page_md5": "52b8761a011eae861bb3518ea2685698",
"small_chat_md5": "cd1b0184a9133cc7f0f688ab21b713d9"
},
"restored": {
"users": "1000",
"chats": "4021",
"chat_members": "8600",
"messages": "200000",
"all_messages_md5": "f3e491b7ebfb52972c8ee73470a90926",
"big_first_page_md5": "516a32c3f0dce2566e84161528ea595c",
"big_d90_page_md5": "52b8761a011eae861bb3518ea2685698",
"small_chat_md5": "cd1b0184a9133cc7f0f688ab21b713d9"
},
"mismatches": [],
"concurrent_writes": {
"committed_before_dump_start": 3787,
"committed_total": 11172,
"present_in_backup": 4482,
"lost_after_snapshot": 6690
},
"api_restore": {
"old_token_users_me": 200,
"message_matches": true
}
}
+111
View File
@@ -0,0 +1,111 @@
# Трек 2: результаты
Среда: `{"date": "2026-10-29T08:55:57Z", "docker_cpus": 12, "docker_memory_gib": 1.9, "docker_server": "27.2.0", "postgres": "17.11", "shared_buffers": "128MB"}`
## Чтение страницы истории (LIMIT 51), медиана из 15 прогонов, мс
| запрос | pk_only | chat_id | created_at_id | chat_created_id |
|---|---|---|---|---|
| big_first | 31.636 | 29.135 | 0.055 | 0.057 |
| big_d50_keyset | 29.115 | 28.754 | 0.056 | 0.048 |
| big_d50_offset | 116.405 | 114.655 | 22.942 | 11.673 |
| big_d90_keyset | 25.118 | 25.870 | 0.057 | 0.054 |
| big_d90_offset | 135.534 | 130.247 | 41.109 | 132.109 |
| medium_first | 23.077 | 3.504 | 0.349 | 0.051 |
| medium_d50_keyset | 26.500 | 3.528 | 0.419 | 0.056 |
| medium_d50_offset | 24.115 | 6.258 | 23.305 | 0.430 |
| medium_d90_keyset | 23.375 | 3.442 | 0.354 | 0.057 |
| medium_d90_offset | 23.633 | 6.063 | 23.641 | 5.539 |
| small_first | 20.085 | 0.061 | 21.749 | 0.039 |
| small_d50_keyset | 22.948 | 0.064 | 24.374 | 0.050 |
| small_d50_offset | 21.521 | 0.079 | 21.753 | 0.038 |
| small_d90_keyset | 22.477 | 0.067 | 0.824 | 0.038 |
| small_d90_offset | 22.451 | 0.087 | 20.675 | 0.046 |
## Буферы (shared hit + read) на запрос
| запрос | pk_only | chat_id | created_at_id | chat_created_id |
|---|---|---|---|---|
| big_first | 12361 | 12361 | 9 | 9 |
| big_d50_keyset | 12303 | 12303 | 18 | 13 |
| big_d50_offset | 12361 | 12361 | 9806 | 8064 |
| big_d90_keyset | 12303 | 12303 | 17 | 11 |
| big_d90_offset | 12361 | 12361 | 17650 | 12361 |
| medium_first | 12361 | 2695 | 327 | 50 |
| medium_d50_keyset | 12303 | 2695 | 375 | 48 |
| medium_d50_offset | 12361 | 2695 | 12361 | 1408 |
| medium_d90_keyset | 12303 | 2695 | 314 | 49 |
| medium_d90_offset | 12361 | 2695 | 12361 | 2713 |
| small_first | 12361 | 13 | 12361 | 13 |
| small_d50_keyset | 12273 | 13 | 12273 | 8 |
| small_d50_offset | 12361 | 13 | 12361 | 13 |
| small_d90_keyset | 12273 | 13 | 548 | 4 |
| small_d90_offset | 12361 | 13 | 12361 | 13 |
## Планы
- pk_only / big_first: `Limit > Gather Merge > Sort > Seq Scan`
- pk_only / big_d90_keyset: `Limit > Gather Merge > Sort > Seq Scan`
- pk_only / big_d90_offset: `Limit > Gather Merge > Sort > Seq Scan`
- pk_only / small_first: `Limit > Gather Merge > Sort > Seq Scan`
- chat_id / big_first: `Limit > Gather Merge > Sort > Seq Scan`
- chat_id / big_d90_keyset: `Limit > Gather Merge > Sort > Seq Scan`
- chat_id / big_d90_offset: `Limit > Gather Merge > Sort > Seq Scan`
- chat_id / small_first: `Limit > Sort > Index Scan(bench_chat_idx)`
- created_at_id / big_first: `Limit > Index Scan(bench_time_idx)`
- created_at_id / big_d90_keyset: `Limit > Index Scan(bench_time_idx)`
- created_at_id / big_d90_offset: `Limit > Index Scan(bench_time_idx)`
- created_at_id / small_first: `Limit > Gather Merge > Sort > Seq Scan`
- chat_created_id / big_first: `Limit > Index Scan(messages_chat_history_idx)`
- chat_created_id / big_d90_keyset: `Limit > Index Scan(messages_chat_history_idx)`
- chat_created_id / big_d90_offset: `Limit > Gather Merge > Sort > Seq Scan`
- chat_created_id / small_first: `Limit > Index Scan(messages_chat_history_idx)`
## Индексы: размер и время построения
| вариант | размер индексов, MiB | построение, с |
|---|---|---|
| pk_only | 0.0 | 0.00 |
| chat_id | 1.5 | 0.43 |
| created_at_id | 7.8 | 0.48 |
| chat_created_id | 11.2 | 0.53 |
## Запись
Пакет: EXPLAIN ANALYZE INSERT 20000 строк в транзакции с ROLLBACK, после CHECKPOINT (медиана 5) — без шума fsync commit. pgbench: по одной строке на транзакцию с COMMIT, 4 клиента, 10 с x 5 повторов.
| вариант | INSERT (таблица+индексы), мс/1000 | FK-проверка, мс/1000 | всего, мс/1000 | WAL на строку, байт | pgbench TPS медиана [min..max] | latency, мс |
|---|---|---|---|---|---|---|
| pk_only | 9.80 | 31.30 | 41.46 | 2793 | 784.2 [528.9..3583.6] | 5.101 |
| chat_id | 11.24 | 30.13 | 41.14 | 2951 | 3541.4 [2776.1..3601.4] | 1.129 |
| created_at_id | 10.85 | 30.81 | 41.22 | 2877 | 3491.3 [3477.0..3522.1] | 1.146 |
| chat_created_id | 11.79 | 31.32 | 43.23 | 3036 | 3505.2 [2773.7..3540.0] | 1.141 |
| chat_created_id_plus_time | 12.78 | 30.83 | 44.16 | 3121 | 3552.6 [783.2..3578.8] | 1.126 |
## Backup -> restore
| этап | секунд |
|---|---|
| dump_bench | 1.69 |
| dump_messenger | 0.51 |
| copy | 1.52 |
| restore_bench | 2.36 |
| restore_messenger | 0.42 |
| analyze | 0.74 |
| api_restore_ready | 6.74 |
| **итого (RTO на этом стенде)** | **13.98** |
Размер bench.dump: 13.4 MiB. Несовпадения контрольных сумм: нет.
Запись во время дампа: {"committed_before_dump_start": 3787, "committed_total": 11172, "present_in_backup": 4482, "lost_after_snapshot": 6690}.
API на восстановленной БД: {"old_token_users_me": 200, "message_matches": true}.
| проверка | источник | восстановлено |
|---|---|---|
| users | `1000` | `1000` |
| chats | `4021` | `4021` |
| chat_members | `8600` | `8600` |
| messages | `200000` | `200000` |
| all_messages_md5 | `f3e491b7ebfb52972c8ee73470a90926` | `f3e491b7ebfb52972c8ee73470a90926` |
| big_first_page_md5 | `516a32c3f0dce2566e84161528ea595c` | `516a32c3f0dce2566e84161528ea595c` |
| big_d90_page_md5 | `52b8761a011eae861bb3518ea2685698` | `52b8761a011eae861bb3518ea2685698` |
| small_chat_md5 | `cd1b0184a9133cc7f0f688ab21b713d9` | `cd1b0184a9133cc7f0f688ab21b713d9` |
+386
View File
@@ -0,0 +1,386 @@
{
"environment": {
"date": "2026-10-29T09:10:50Z",
"docker_cpus": 12,
"docker_memory_gib": 1.9,
"docker_server": "27.2.0",
"postgres": "17.11",
"shared_buffers": "128MB"
},
"seconds": 10,
"clients": 4,
"repeats": 5,
"bulk_rows": 20000,
"variants": {
"pk_only": {
"bulk_insert_ms_per_1000": 9.8,
"bulk_fk_ms_per_1000": 31.3,
"bulk_total_ms_per_1000": 41.46,
"bulk_wal_bytes_per_row": 2793,
"tps_median": 784.2,
"tps_min": 528.9,
"tps_max": 3583.6,
"latency_ms_median": 5.101,
"bulks": [
{
"insert_ms_per_1000": 9.8,
"fk_ms_per_1000": 31.52,
"total_ms_per_1000": 41.47,
"wal_bytes_per_row": 2793
},
{
"insert_ms_per_1000": 11.09,
"fk_ms_per_1000": 30.56,
"total_ms_per_1000": 41.76,
"wal_bytes_per_row": 2793
},
{
"insert_ms_per_1000": 9.43,
"fk_ms_per_1000": 31.91,
"total_ms_per_1000": 41.46,
"wal_bytes_per_row": 2793
},
{
"insert_ms_per_1000": 9.95,
"fk_ms_per_1000": 31.3,
"total_ms_per_1000": 41.36,
"wal_bytes_per_row": 2793
},
{
"insert_ms_per_1000": 9.5,
"fk_ms_per_1000": 30.65,
"total_ms_per_1000": 40.27,
"wal_bytes_per_row": 2793
}
],
"attempts": [
{
"tps": 3513.544906,
"latency_ms": 1.138,
"transactions": 35120,
"wal_bytes_per_insert": 1769
},
{
"tps": 3583.592907,
"latency_ms": 1.116,
"transactions": 35820,
"wal_bytes_per_insert": 1741
},
{
"tps": 784.216324,
"latency_ms": 5.101,
"transactions": 7843,
"wal_bytes_per_insert": 6893
},
{
"tps": 661.032239,
"latency_ms": 6.051,
"transactions": 6616,
"wal_bytes_per_insert": 7164
},
{
"tps": 528.938348,
"latency_ms": 7.562,
"transactions": 5289,
"wal_bytes_per_insert": 7348
}
]
},
"chat_id": {
"bulk_insert_ms_per_1000": 11.24,
"bulk_fk_ms_per_1000": 30.13,
"bulk_total_ms_per_1000": 41.14,
"bulk_wal_bytes_per_row": 2951,
"tps_median": 3541.4,
"tps_min": 2776.1,
"tps_max": 3601.4,
"latency_ms_median": 1.129,
"bulks": [
{
"insert_ms_per_1000": 11.24,
"fk_ms_per_1000": 30.74,
"total_ms_per_1000": 42.09,
"wal_bytes_per_row": 2946
},
{
"insert_ms_per_1000": 11.26,
"fk_ms_per_1000": 29.76,
"total_ms_per_1000": 41.14,
"wal_bytes_per_row": 2954
},
{
"insert_ms_per_1000": 10.71,
"fk_ms_per_1000": 30.13,
"total_ms_per_1000": 40.95,
"wal_bytes_per_row": 2951
},
{
"insert_ms_per_1000": 11.43,
"fk_ms_per_1000": 30.85,
"total_ms_per_1000": 42.4,
"wal_bytes_per_row": 2951
},
{
"insert_ms_per_1000": 11.08,
"fk_ms_per_1000": 29.95,
"total_ms_per_1000": 41.14,
"wal_bytes_per_row": 2954
}
],
"attempts": [
{
"tps": 3526.596885,
"latency_ms": 1.134,
"transactions": 35252,
"wal_bytes_per_insert": 1896
},
{
"tps": 3541.427104,
"latency_ms": 1.129,
"transactions": 35402,
"wal_bytes_per_insert": 1887
},
{
"tps": 3552.604368,
"latency_ms": 1.126,
"transactions": 35508,
"wal_bytes_per_insert": 1885
},
{
"tps": 3601.44502,
"latency_ms": 1.111,
"transactions": 35996,
"wal_bytes_per_insert": 1866
},
{
"tps": 2776.112606,
"latency_ms": 1.441,
"transactions": 27749,
"wal_bytes_per_insert": 2310
}
]
},
"created_at_id": {
"bulk_insert_ms_per_1000": 10.85,
"bulk_fk_ms_per_1000": 30.81,
"bulk_total_ms_per_1000": 41.22,
"bulk_wal_bytes_per_row": 2877,
"tps_median": 3491.3,
"tps_min": 3477.0,
"tps_max": 3522.1,
"latency_ms_median": 1.146,
"bulks": [
{
"insert_ms_per_1000": 10.85,
"fk_ms_per_1000": 30.26,
"total_ms_per_1000": 41.22,
"wal_bytes_per_row": 2877
},
{
"insert_ms_per_1000": 10.84,
"fk_ms_per_1000": 30.82,
"total_ms_per_1000": 41.78,
"wal_bytes_per_row": 2877
},
{
"insert_ms_per_1000": 11.47,
"fk_ms_per_1000": 30.81,
"total_ms_per_1000": 42.39,
"wal_bytes_per_row": 2877
},
{
"insert_ms_per_1000": 10.89,
"fk_ms_per_1000": 30.13,
"total_ms_per_1000": 41.12,
"wal_bytes_per_row": 2877
},
{
"insert_ms_per_1000": 9.92,
"fk_ms_per_1000": 30.84,
"total_ms_per_1000": 40.88,
"wal_bytes_per_row": 2877
}
],
"attempts": [
{
"tps": 3522.068729,
"latency_ms": 1.136,
"transactions": 35205,
"wal_bytes_per_insert": 1850
},
{
"tps": 3476.990375,
"latency_ms": 1.15,
"transactions": 34754,
"wal_bytes_per_insert": 1869
},
{
"tps": 3491.314235,
"latency_ms": 1.146,
"transactions": 34896,
"wal_bytes_per_insert": 1864
},
{
"tps": 3486.483623,
"latency_ms": 1.147,
"transactions": 34848,
"wal_bytes_per_insert": 1866
},
{
"tps": 3517.088554,
"latency_ms": 1.137,
"transactions": 35154,
"wal_bytes_per_insert": 1854
}
]
},
"chat_created_id": {
"bulk_insert_ms_per_1000": 11.79,
"bulk_fk_ms_per_1000": 31.32,
"bulk_total_ms_per_1000": 43.23,
"bulk_wal_bytes_per_row": 3036,
"tps_median": 3505.2,
"tps_min": 2773.7,
"tps_max": 3540.0,
"latency_ms_median": 1.141,
"bulks": [
{
"insert_ms_per_1000": 12.47,
"fk_ms_per_1000": 32.83,
"total_ms_per_1000": 45.41,
"wal_bytes_per_row": 3060
},
{
"insert_ms_per_1000": 11.61,
"fk_ms_per_1000": 31.36,
"total_ms_per_1000": 43.1,
"wal_bytes_per_row": 3036
},
{
"insert_ms_per_1000": 11.07,
"fk_ms_per_1000": 29.45,
"total_ms_per_1000": 40.65,
"wal_bytes_per_row": 3036
},
{
"insert_ms_per_1000": 13.25,
"fk_ms_per_1000": 30.65,
"total_ms_per_1000": 44.01,
"wal_bytes_per_row": 3036
},
{
"insert_ms_per_1000": 11.79,
"fk_ms_per_1000": 31.32,
"total_ms_per_1000": 43.23,
"wal_bytes_per_row": 3036
}
],
"attempts": [
{
"tps": 3531.073941,
"latency_ms": 1.133,
"transactions": 35297,
"wal_bytes_per_insert": 1976
},
{
"tps": 3481.74199,
"latency_ms": 1.149,
"transactions": 34801,
"wal_bytes_per_insert": 1984
},
{
"tps": 3540.023992,
"latency_ms": 1.13,
"transactions": 35383,
"wal_bytes_per_insert": 1959
},
{
"tps": 3505.193506,
"latency_ms": 1.141,
"transactions": 35033,
"wal_bytes_per_insert": 1970
},
{
"tps": 2773.668269,
"latency_ms": 1.442,
"transactions": 27725,
"wal_bytes_per_insert": 2375
}
]
},
"chat_created_id_plus_time": {
"bulk_insert_ms_per_1000": 12.78,
"bulk_fk_ms_per_1000": 30.83,
"bulk_total_ms_per_1000": 44.16,
"bulk_wal_bytes_per_row": 3121,
"tps_median": 3552.6,
"tps_min": 783.2,
"tps_max": 3578.8,
"latency_ms_median": 1.126,
"bulks": [
{
"insert_ms_per_1000": 13.27,
"fk_ms_per_1000": 30.77,
"total_ms_per_1000": 44.16,
"wal_bytes_per_row": 3145
},
{
"insert_ms_per_1000": 12.78,
"fk_ms_per_1000": 31.66,
"total_ms_per_1000": 44.55,
"wal_bytes_per_row": 3120
},
{
"insert_ms_per_1000": 13.64,
"fk_ms_per_1000": 30.82,
"total_ms_per_1000": 44.57,
"wal_bytes_per_row": 3121
},
{
"insert_ms_per_1000": 12.73,
"fk_ms_per_1000": 30.83,
"total_ms_per_1000": 43.68,
"wal_bytes_per_row": 3121
},
{
"insert_ms_per_1000": 11.77,
"fk_ms_per_1000": 31.53,
"total_ms_per_1000": 43.43,
"wal_bytes_per_row": 3121
}
],
"attempts": [
{
"tps": 3554.292554,
"latency_ms": 1.125,
"transactions": 35526,
"wal_bytes_per_insert": 2052
},
{
"tps": 3552.622838,
"latency_ms": 1.126,
"transactions": 35510,
"wal_bytes_per_insert": 2039
},
{
"tps": 3578.846119,
"latency_ms": 1.118,
"transactions": 35771,
"wal_bytes_per_insert": 2025
},
{
"tps": 3376.236061,
"latency_ms": 1.185,
"transactions": 33745,
"wal_bytes_per_insert": 2115
},
{
"tps": 783.210401,
"latency_ms": 5.107,
"transactions": 7833,
"wal_bytes_per_insert": 7365
}
]
}
}
}