From 2cf90c9e14563b1c13be673bdc7ee0c497c485db Mon Sep 17 00:00:00 2001 From: mo Date: Thu, 25 Jun 2026 01:24:35 +0000 Subject: [PATCH] Fix Trino benchmark and sample queries for valid syntax and parallel demo --- api/sql_console.py | 16 ++++++++-------- ui/src/components/features/SqlWorkbench.tsx | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/sql_console.py b/api/sql_console.py index 335561b..992179d 100644 --- a/api/sql_console.py +++ b/api/sql_console.py @@ -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", }, } diff --git a/ui/src/components/features/SqlWorkbench.tsx b/ui/src/components/features/SqlWorkbench.tsx index c63f182..0f56c20 100644 --- a/ui/src/components/features/SqlWorkbench.tsx +++ b/ui/src/components/features/SqlWorkbench.tsx @@ -157,7 +157,7 @@ export function SqlWorkbench({ engine }: Props) { {benchmark?.comparison && (
- Benchmark (2M rows): + Benchmark (5M parallel compute): PostgreSQL {benchmark.comparison.postgres_ms}ms {' · '} Trino {benchmark.comparison.trino_ms}ms