forked from mtusi2026/mtusi2026lab2
объяснение 2 трека
This commit is contained in:
Binary file not shown.
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"hypothesis": "Keyset pagination on (chat_id, created_at, id) avoids large offsets; redundant (chat_id)-only index does not improve reads but slows writes.",
|
||||
"hot_chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"hot_chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"read_plans": {
|
||||
"keyset_limit_50": {
|
||||
"node_type": "Index Only Scan",
|
||||
"index_name": "messages_chat_history_idx",
|
||||
"execution_ms": 0.061,
|
||||
"execution_ms": 0.323,
|
||||
"plan_rows": 50
|
||||
},
|
||||
"offset_50000_limit_50": {
|
||||
"node_type": "Index Only Scan",
|
||||
"index_name": "messages_chat_history_idx",
|
||||
"execution_ms": 6.117,
|
||||
"execution_ms": 5.577,
|
||||
"plan_rows": 50
|
||||
},
|
||||
"keyset_with_extra_chat_id_index": {
|
||||
"node_type": "Index Only Scan",
|
||||
"index_name": "messages_chat_history_idx",
|
||||
"execution_ms": 0.052,
|
||||
"execution_ms": 0.055,
|
||||
"plan_rows": 50
|
||||
}
|
||||
},
|
||||
"write_messages_per_second": {
|
||||
"with_extra_chat_id_index": 23192.1,
|
||||
"production_indexes_only": 38756.3
|
||||
"with_extra_chat_id_index": 17808.1,
|
||||
"production_indexes_only": 22943.3
|
||||
}
|
||||
}
|
||||
@@ -1,69 +1,69 @@
|
||||
{
|
||||
"source": {
|
||||
"messages": 116022,
|
||||
"users": 88,
|
||||
"messages": 113003,
|
||||
"users": 8,
|
||||
"sample": [
|
||||
{
|
||||
"id": "ffb54a59-afe2-41b7-9d55-e53a68117a84",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "ffdc1b38-be68-4b22-b3ac-9cfa0a8b95e7",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff90fc55-75ed-4633-85da-219d49656ebe",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "ff7ceafd-9fd1-4880-8a05-607961c68543",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff77cfb7-e1a3-45e3-ad54-c9b88a79cc1b",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "fef0853c-9b43-4f1d-bd5f-2941a08eeac1",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff102c2f-a3f2-4e39-a9c5-9a997a49f157",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "fee4413a-af81-4a84-8f4a-0c6704462f02",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "fe8a483b-94c8-40fc-a5d4-b0e2fd2602fc",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "febc6e0a-110e-4cda-8320-7fc88e5faf52",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
}
|
||||
]
|
||||
},
|
||||
"restored": {
|
||||
"messages": 116022,
|
||||
"users": 88,
|
||||
"messages": 113003,
|
||||
"users": 8,
|
||||
"sample": [
|
||||
{
|
||||
"id": "ffb54a59-afe2-41b7-9d55-e53a68117a84",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "ffdc1b38-be68-4b22-b3ac-9cfa0a8b95e7",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff90fc55-75ed-4633-85da-219d49656ebe",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "ff7ceafd-9fd1-4880-8a05-607961c68543",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff77cfb7-e1a3-45e3-ad54-c9b88a79cc1b",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "fef0853c-9b43-4f1d-bd5f-2941a08eeac1",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "ff102c2f-a3f2-4e39-a9c5-9a997a49f157",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "fee4413a-af81-4a84-8f4a-0c6704462f02",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
},
|
||||
{
|
||||
"id": "fe8a483b-94c8-40fc-a5d4-b0e2fd2602fc",
|
||||
"chat_id": "01aeb3d4-8235-4964-8981-ace0cec560df",
|
||||
"id": "febc6e0a-110e-4cda-8320-7fc88e5faf52",
|
||||
"chat_id": "9d97f9d9-1ad0-4ab6-b95a-f35411c401b6",
|
||||
"text": "w"
|
||||
}
|
||||
]
|
||||
},
|
||||
"counts_match": true,
|
||||
"sample_match": true,
|
||||
"restore_seconds": 3.75,
|
||||
"dump_bytes": 3024158,
|
||||
"restore_seconds": 3.6,
|
||||
"dump_bytes": 2945586,
|
||||
"data_loss_boundary": "Logical pg_dump is consistent at dump start; concurrent writes during dump are not included. WAL/PITR not used — RPO equals changes after dump began."
|
||||
}
|
||||
@@ -86,6 +86,13 @@ def main():
|
||||
conn.execute('DROP INDEX IF EXISTS messages_chat_id_only_idx')
|
||||
conn.execute('CREATE INDEX messages_chat_id_only_idx ON messages (chat_id)')
|
||||
conn.commit()
|
||||
|
||||
indexes = conn.execute(
|
||||
"SELECT indexname, indexdef FROM pg_indexes "
|
||||
"WHERE tablename = 'messages' ORDER BY indexname"
|
||||
).fetchall()
|
||||
print(indexes)
|
||||
|
||||
plan_keyset_with_extra = explain(conn, keyset_sql, (hot_id,))
|
||||
write_before = insert_batch(conn, hot_id, user_id, 500)
|
||||
conn.execute('DROP INDEX IF EXISTS messages_chat_id_only_idx')
|
||||
|
||||
Reference in New Issue
Block a user