The app for independent voices

Trino runs faster than Spark for most queries and is the go-to query engine at Meta!It is SQL-based and has levels to it:

Level 1: Core Queries

SELECT, FROM, WHERE, GROUP BY, HAVING, LIMIT

These basics are identical to basic SQL you know, but in Trino they scale across distributed queries (data split across nodes).

Level 2: Working Across Sources

Mastering JOINs between different catalogs: you can join Postgres + Iceberg + S3 in one query.

Use WITH (CTEs) to simplify complex multi-source pipelines.Trino doesn’t support everything (e.g., no updates/inserts to all sources), but read/query federation is its superpower.

Understand broadcast joins vs partitioned joins. Trino decides based on data size, so skewed data can hurt performance. Trino doesn't spill to disk like Spark on skew, it fails instead!

Level 3: Advanced Functions

Window functions work beautifully in Trino:Function: ROW_NUMBER(), RANK(), SUM(), lambda functions like REDUCE AND TRANSFORM_VALUES

Window definition: PARTITION BY, ORDER BY, ROWS / RANGE.

Use cases: rolling averages, sessionization, top-N per group, managing complex data types

Trino also supports approximate functions (e.g., approx_distinct) for big data. This function runs 100x faster than COUNT DISTINCT and is a much better option for queries that only need to be 99.9% accurate!

Level 4: Performance Engineering

Trino queries run across worker nodes to split the data into a distributed plan to make teamwork make the dream work!

Use EXPLAIN (ANALYZE) to see distributed plans (what’s broadcast, what’s partitioned).

Optimize joins by ensuring the smaller table is broadcast, or pre-bucket tables on the same keys.

Partition pruning matters: Iceberg/Delta/Hive tables benefit from well-chosen partition columns. Watch out for cross-joins or big shuffles. Distributed SQL makes bad queries very expensive.

To learn more about all things Trino, sign up for Starburst’s free virtual Trino Day event (October 22nd and 23rd): register here: starburst.io/ai-and-dat… (signups from this link have a chance of winning free Trino swag)

Sep 25
at
6:21 PM
Relevant people

Log in or sign up

Join the most interesting and insightful discussions.