This commit is contained in:
@@ -0,0 +1,916 @@
|
||||
{
|
||||
"run_utc": "2026-10-07T06:01:48.126545+00:00",
|
||||
"environment": {
|
||||
"host_platform": "macOS-27.0-arm64-arm-64bit-Mach-O",
|
||||
"host_architecture": "arm64",
|
||||
"host_logical_cpus": 10,
|
||||
"host_memory_bytes": 17179869184,
|
||||
"postgres_image": "postgres:16.4-alpine",
|
||||
"postgres_version": "16.4",
|
||||
"postgres_container_memory_limit_bytes": 0,
|
||||
"postgres_container_cpu_limit_nanos": 0,
|
||||
"warmup": "initial data load followed by ANALYZE; plan query is executed 5 times",
|
||||
"postgres_memory_setting": "128MB",
|
||||
"postgres_work_mem": "4MB"
|
||||
},
|
||||
"method": {
|
||||
"rows_per_index_variant": 100000,
|
||||
"distribution": "80,000 messages in one chat; 20,000 distributed evenly across 100 chats",
|
||||
"warmup": "ANALYZE followed by five executed EXPLAIN ANALYZE samples per query",
|
||||
"query": "SELECT id, created_at, text FROM messages WHERE chat_id = 2 AND (created_at, id) > (timestamptz '2025-01-01 23:36:40+00', 0) ORDER BY created_at, id LIMIT 25"
|
||||
},
|
||||
"query_plans": {
|
||||
"chat_id_only": {
|
||||
"index": "(chat_id)",
|
||||
"samples": [
|
||||
{
|
||||
"execution_ms": 0.308,
|
||||
"planning_ms": 0.492,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 206,
|
||||
"shared_read_blocks": 2,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.42,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.233,
|
||||
"Actual Total Time": 0.236,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 206,
|
||||
"Shared Read Blocks": 2,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Sort",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.43,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.232,
|
||||
"Actual Total Time": 0.234,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Sort Key": [
|
||||
"created_at",
|
||||
"id"
|
||||
],
|
||||
"Sort Method": "top-N heapsort",
|
||||
"Sort Space Used": 26,
|
||||
"Sort Space Type": "Memory",
|
||||
"Shared Hit Blocks": 206,
|
||||
"Shared Read Blocks": 2,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_only_idx",
|
||||
"Relation Name": "messages_chat_only",
|
||||
"Alias": "messages_chat_only",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 25.65,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.07,
|
||||
"Actual Total Time": 0.194,
|
||||
"Actual Rows": 150,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = 2)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Filter": "(ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0))",
|
||||
"Rows Removed by Filter": 50,
|
||||
"Shared Hit Blocks": 200,
|
||||
"Shared Read Blocks": 2,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.29,
|
||||
"planning_ms": 0.41,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 208,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.42,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.236,
|
||||
"Actual Total Time": 0.239,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Sort",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.43,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.235,
|
||||
"Actual Total Time": 0.236,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Sort Key": [
|
||||
"created_at",
|
||||
"id"
|
||||
],
|
||||
"Sort Method": "top-N heapsort",
|
||||
"Sort Space Used": 26,
|
||||
"Sort Space Type": "Memory",
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_only_idx",
|
||||
"Relation Name": "messages_chat_only",
|
||||
"Alias": "messages_chat_only",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 25.65,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.059,
|
||||
"Actual Total Time": 0.187,
|
||||
"Actual Rows": 150,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = 2)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Filter": "(ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0))",
|
||||
"Rows Removed by Filter": 50,
|
||||
"Shared Hit Blocks": 202,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.297,
|
||||
"planning_ms": 0.407,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 208,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.42,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.248,
|
||||
"Actual Total Time": 0.252,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Sort",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.43,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.247,
|
||||
"Actual Total Time": 0.249,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Sort Key": [
|
||||
"created_at",
|
||||
"id"
|
||||
],
|
||||
"Sort Method": "top-N heapsort",
|
||||
"Sort Space Used": 26,
|
||||
"Sort Space Type": "Memory",
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_only_idx",
|
||||
"Relation Name": "messages_chat_only",
|
||||
"Alias": "messages_chat_only",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 25.65,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.063,
|
||||
"Actual Total Time": 0.208,
|
||||
"Actual Rows": 150,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = 2)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Filter": "(ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0))",
|
||||
"Rows Removed by Filter": 50,
|
||||
"Shared Hit Blocks": 202,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.334,
|
||||
"planning_ms": 0.414,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 208,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.42,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.259,
|
||||
"Actual Total Time": 0.262,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Sort",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.43,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.258,
|
||||
"Actual Total Time": 0.259,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Sort Key": [
|
||||
"created_at",
|
||||
"id"
|
||||
],
|
||||
"Sort Method": "top-N heapsort",
|
||||
"Sort Space Used": 26,
|
||||
"Sort Space Type": "Memory",
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_only_idx",
|
||||
"Relation Name": "messages_chat_only",
|
||||
"Alias": "messages_chat_only",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 25.65,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.061,
|
||||
"Actual Total Time": 0.191,
|
||||
"Actual Rows": 150,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = 2)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Filter": "(ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0))",
|
||||
"Rows Removed by Filter": 50,
|
||||
"Shared Hit Blocks": 202,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.271,
|
||||
"planning_ms": 0.454,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 208,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.42,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.223,
|
||||
"Actual Total Time": 0.226,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Sort",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 26.36,
|
||||
"Total Cost": 26.43,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.222,
|
||||
"Actual Total Time": 0.223,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Sort Key": [
|
||||
"created_at",
|
||||
"id"
|
||||
],
|
||||
"Sort Method": "top-N heapsort",
|
||||
"Sort Space Used": 26,
|
||||
"Sort Space Type": "Memory",
|
||||
"Shared Hit Blocks": 208,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_only_idx",
|
||||
"Relation Name": "messages_chat_only",
|
||||
"Alias": "messages_chat_only",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 25.65,
|
||||
"Plan Rows": 29,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.059,
|
||||
"Actual Total Time": 0.183,
|
||||
"Actual Rows": 150,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = 2)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Filter": "(ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0))",
|
||||
"Rows Removed by Filter": 50,
|
||||
"Shared Hit Blocks": 202,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"composite_history": {
|
||||
"index": "(chat_id, created_at, id)",
|
||||
"samples": [
|
||||
{
|
||||
"execution_ms": 0.201,
|
||||
"planning_ms": 0.446,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 25,
|
||||
"shared_read_blocks": 3,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 50.73,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.045,
|
||||
"Actual Total Time": 0.156,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 25,
|
||||
"Shared Read Blocks": 3,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages_composite",
|
||||
"Alias": "messages_composite",
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 60.79,
|
||||
"Plan Rows": 30,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.044,
|
||||
"Actual Total Time": 0.151,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 25,
|
||||
"Shared Read Blocks": 3,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.1,
|
||||
"planning_ms": 0.429,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 28,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 50.73,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.024,
|
||||
"Actual Total Time": 0.048,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages_composite",
|
||||
"Alias": "messages_composite",
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 60.79,
|
||||
"Plan Rows": 30,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.023,
|
||||
"Actual Total Time": 0.045,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.093,
|
||||
"planning_ms": 0.433,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 28,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 50.73,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.02,
|
||||
"Actual Total Time": 0.046,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages_composite",
|
||||
"Alias": "messages_composite",
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 60.79,
|
||||
"Plan Rows": 30,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.019,
|
||||
"Actual Total Time": 0.043,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.097,
|
||||
"planning_ms": 0.444,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 28,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 50.73,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.02,
|
||||
"Actual Total Time": 0.044,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages_composite",
|
||||
"Alias": "messages_composite",
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 60.79,
|
||||
"Plan Rows": 30,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.019,
|
||||
"Actual Total Time": 0.041,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"execution_ms": 0.083,
|
||||
"planning_ms": 0.473,
|
||||
"actual_rows": 25,
|
||||
"shared_hit_blocks": 28,
|
||||
"shared_read_blocks": 0,
|
||||
"plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 50.73,
|
||||
"Plan Rows": 25,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.02,
|
||||
"Actual Total Time": 0.044,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages_composite",
|
||||
"Alias": "messages_composite",
|
||||
"Startup Cost": 0.42,
|
||||
"Total Cost": 60.79,
|
||||
"Plan Rows": 30,
|
||||
"Plan Width": 41,
|
||||
"Actual Startup Time": 0.019,
|
||||
"Actual Total Time": 0.041,
|
||||
"Actual Rows": 25,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 23:36:40+00'::timestamp with time zone, 0)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 28,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"write_cost": {
|
||||
"chat_id_only": {
|
||||
"samples": [
|
||||
{
|
||||
"execution_ms": 5.747,
|
||||
"planning_ms": 0.092,
|
||||
"shared_write_blocks": 25
|
||||
},
|
||||
{
|
||||
"execution_ms": 5.886,
|
||||
"planning_ms": 0.068,
|
||||
"shared_write_blocks": 40
|
||||
},
|
||||
{
|
||||
"execution_ms": 5.27,
|
||||
"planning_ms": 0.064,
|
||||
"shared_write_blocks": 25
|
||||
},
|
||||
{
|
||||
"execution_ms": 5.177,
|
||||
"planning_ms": 0.068,
|
||||
"shared_write_blocks": 24
|
||||
},
|
||||
{
|
||||
"execution_ms": 5.428,
|
||||
"planning_ms": 0.076,
|
||||
"shared_write_blocks": 25
|
||||
}
|
||||
],
|
||||
"median_execution_ms": 5.428,
|
||||
"median_shared_write_blocks": 25,
|
||||
"rows_per_sample": 2000,
|
||||
"rolled_back_after_each_measurement": true
|
||||
},
|
||||
"composite_history": {
|
||||
"samples": [
|
||||
{
|
||||
"execution_ms": 7.341,
|
||||
"planning_ms": 0.068,
|
||||
"shared_write_blocks": 26
|
||||
},
|
||||
{
|
||||
"execution_ms": 8.717,
|
||||
"planning_ms": 0.066,
|
||||
"shared_write_blocks": 120
|
||||
},
|
||||
{
|
||||
"execution_ms": 6.492,
|
||||
"planning_ms": 0.067,
|
||||
"shared_write_blocks": 23
|
||||
},
|
||||
{
|
||||
"execution_ms": 6.163,
|
||||
"planning_ms": 0.064,
|
||||
"shared_write_blocks": 24
|
||||
},
|
||||
{
|
||||
"execution_ms": 7.218,
|
||||
"planning_ms": 0.066,
|
||||
"shared_write_blocks": 25
|
||||
}
|
||||
],
|
||||
"median_execution_ms": 7.218,
|
||||
"median_shared_write_blocks": 25,
|
||||
"rows_per_sample": 2000,
|
||||
"rolled_back_after_each_measurement": true
|
||||
}
|
||||
},
|
||||
"backup_restore": {
|
||||
"format": "pg_dump custom format",
|
||||
"dump_bytes": 1596489,
|
||||
"dump_seconds": 0.3118779160431586,
|
||||
"restore_seconds": 0.38548716699006036,
|
||||
"restored_counts": {
|
||||
"messages_chat_only": 100000,
|
||||
"messages_composite": 100000
|
||||
},
|
||||
"source_selected_checksums": {
|
||||
"messages_chat_only": "59b4843022f2d85760e29d81bb6ca73c",
|
||||
"messages_composite": "59b4843022f2d85760e29d81bb6ca73c"
|
||||
},
|
||||
"restored_selected_checksums": {
|
||||
"messages_chat_only": "59b4843022f2d85760e29d81bb6ca73c",
|
||||
"messages_composite": "59b4843022f2d85760e29d81bb6ca73c"
|
||||
},
|
||||
"verification": "PASS"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# Lab2 level-5 track 2 — query plans and recovery
|
||||
|
||||
- Run UTC: 2026-10-07T06:01:48.126545+00:00
|
||||
- Host: macOS-27.0-arm64-arm-64bit-Mach-O (arm64), logical CPUs: 10
|
||||
- Host physical memory: 17179869184 bytes.
|
||||
- PostgreSQL: 16.4 in `postgres:16.4-alpine`; container memory limit: 0 bytes; CPU limit: 0 nanocores (0 means unlimited).
|
||||
- Dataset: 100,000 synthetic rows in each comparison table; one chat has 80,000 rows and 100 small chats share the remaining 20,000. Only generated text is used.
|
||||
- Query: keyset page from chat 2, identical SELECT and cursor for both indexes; each plan was executed five times after ANALYZE.
|
||||
|
||||
| Index | Median execution (ms) | Shared hits | Shared reads | Rows |
|
||||
|---|---:|---:|---:|---:|
|
||||
| `(chat_id)` | 0.297 | 206 | 2 | 25 |
|
||||
| `(chat_id, created_at, id)` | 0.097 | 25 | 3 | 25 |
|
||||
|
||||
| Index | Median time for 2,000 inserted rows (ms) | Median shared write blocks |
|
||||
|---|---:|---:|
|
||||
| `(chat_id)` | 5.428 | 25 |
|
||||
| `(chat_id, created_at, id)` | 7.218 | 25 |
|
||||
|
||||
Each write-cost query was measured five times inside a transaction and rolled back. This isolates execution and index-maintenance work but does not measure durable commit/fsync latency.
|
||||
|
||||
Backup/restore: custom-format dump 1596489 bytes; dump 0.312s; restore into a separately created empty database 0.385s. Restored row counts and deterministic checksums for the selected messages were verified: **PASS**.
|
||||
|
||||
Raw JSON plans, samples, environment and restore checksums are in `track5_query_restore.json`. This single-host synthetic run is a reproducible comparison, not a production capacity or HA claim.
|
||||
Reference in New Issue
Block a user