Fix Trino benchmark and sample queries for valid syntax and parallel demo
This commit is contained in:
+8
-8
@@ -40,19 +40,19 @@ SAMPLES: dict[str, list[dict[str, str]]] = {
|
||||
{"id": "tq1", "label": "Trino version", "sql": "SELECT version()"},
|
||||
{"id": "tq2", "label": "Catalogs", "sql": "SHOW CATALOGS"},
|
||||
{"id": "tq3", "label": "Iceberg schemas", "sql": "SHOW SCHEMAS FROM iceberg"},
|
||||
{"id": "tq4", "label": "Iceberg tables", "sql": "SHOW TABLES FROM iceberg.default"},
|
||||
{"id": "tq4", "label": "Sales tables (federated PG)", "sql": "SHOW TABLES FROM postgres_sales.public"},
|
||||
{"id": "tq5", "label": "Federated PG catalog", "sql": "SHOW SCHEMAS FROM postgres_sales"},
|
||||
{"id": "tq6", "label": "Cluster nodes", "sql": "SELECT node_id, http_uri, state FROM system.runtime.nodes"},
|
||||
{"id": "tq7", "label": "Running queries", "sql": "SELECT query_id, state, user FROM system.runtime.queries WHERE state != 'FINISHED' LIMIT 10"},
|
||||
{"id": "tq8", "label": "Count 1M rows (fast)", "sql": "SELECT count(*) AS rows FROM range(1, 1000000)"},
|
||||
{"id": "tq9", "label": "Explain 5M scan", "sql": "EXPLAIN SELECT count(*) FROM range(1, 5000000)"},
|
||||
{"id": "tq10", "label": "Sum benchmark prep", "sql": "SELECT sum(x) AS total FROM (SELECT x FROM unnest(sequence(1, 500000)) t(x))"},
|
||||
{"id": "tq8", "label": "Count 1M rows (parallel)", "sql": "SELECT count(*) AS rows FROM unnest(sequence(1,1000)) a(x) CROSS JOIN unnest(sequence(1,1000)) b(y)"},
|
||||
{"id": "tq9", "label": "Federated sales by region", "sql": "SELECT region, count(*) AS orders FROM postgres_sales.public.sales_orders WHERE order_id < 500000 GROUP BY region ORDER BY orders DESC"},
|
||||
{"id": "tq10", "label": "Parallel sin() 1M rows", "sql": "SELECT sum(sin(a.x)) AS total FROM unnest(sequence(1,1000)) a(x) CROSS JOIN unnest(sequence(1,1000)) b(y)"},
|
||||
],
|
||||
}
|
||||
|
||||
BENCHMARK_SQL = {
|
||||
"postgres": "SELECT count(*) AS rows FROM generate_series(1, 2000000)",
|
||||
"trino": "SELECT count(*) AS rows FROM range(1, 2000000)",
|
||||
"postgres": "SELECT sum(sin(i)) AS total FROM generate_series(1, 5000000) i",
|
||||
"trino": "SELECT sum(sin(a.x)) AS total FROM unnest(sequence(1,2500)) a(x) CROSS JOIN unnest(sequence(1,2000)) b(y)",
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ async def execute_sql(body: SqlRequest):
|
||||
|
||||
@router.post("/benchmark")
|
||||
async def benchmark():
|
||||
"""Run equivalent count(*) on Postgres vs Trino to demo lakehouse speed."""
|
||||
"""Parallel analytics: PostgreSQL OLTP vs Trino distributed engine (5M sin() rows)."""
|
||||
results: dict[str, Any] = {}
|
||||
for engine, sql in BENCHMARK_SQL.items():
|
||||
try:
|
||||
@@ -206,6 +206,6 @@ async def benchmark():
|
||||
"trino_ms": tr_ms,
|
||||
"faster": faster,
|
||||
"speedup_factor": speedup,
|
||||
"note": "Same logical workload: count 2M rows — Trino distributed engine vs PostgreSQL OLTP",
|
||||
"note": "5M row parallel compute — Trino distributes across workers; PostgreSQL single-node OLTP",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user