trino-query-optimization

Optimizes slow Trino SQL queries via pushdown enforcement and join tuning.

14|1|Updated May 5, 2026
One-click install
npx skills add https://github.com/ivanshamaev/de-agent-skills --skill trino-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trino-query-optimization
Source: https://github.com/ivanshamaev/de-agent-skills/tree/main/group_skills/trino_group_skills/trino_query_optimization
Command: npx skills add https://github.com/ivanshamaev/de-agent-skills --skill trino-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you diagnose and speed up slow Trino distributed SQL queries by improving filtering, projection, join strategy, dynamic filtering, and execution efficiency so the engine does less work and moves less data.

Core Features & Use Cases

  • Filter and projection pushdown: ensures predicates and selected columns are applied as early as possible (e.g., avoiding full scans and SELECT *).
  • Join optimization and dynamic filtering: chooses broadcast vs partitioned joins, improves join ordering via CBO/ANALYZE, and leverages runtime dynamic filters to reduce scanned data.
  • Shuffle and session tuning: minimizes expensive repartitioning and adjusts session properties (memory, exchange compression, task parallelism) to reduce bottlenecks.

Quick Start

Ask the agent to optimize your slow Trino SQL by checking the execution plan for pushdown failures, inefficient projections, poor join strategy, missing partition pruning, excessive shuffles, and stale statistics, then propose revised SQL and relevant EXPLAIN/SKIIP checks.

Frequently Asked Questions about trino-query-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow Trino SQL queries using execution plans?

Optimize slow Trino SQL queries by analyzing the execution plan to detect pushdown failures, poor join strategies, and missing partition pruning. This process enforces filter and projection pushdown, adjusts session properties, and rewrites SQL to reduce memory pressure and unnecessary scans.

Why does predicate pushdown fail in Trino with Iceberg tables?

Predicate pushdown fails in Trino when filters are not applied early in the Iceberg scan, causing full table scans. Diagnose this by checking the EXPLAIN plan to ensure partition pruning occurs, then rewrite SQL to enforce early filtering and avoid SELECT *.

What is the best way to tune cross-catalog joins in Trino?

Tune cross-catalog joins in Trino by selecting appropriate broadcast versus partitioned join strategies and leveraging runtime dynamic filtering. Running ANALYZE-backed CBO guides join reordering to minimize expensive shuffles and reduce scanned data across JDBC-backed connectors.

Can I reduce shuffle and memory pressure in Trino with session properties?

Reduce shuffle and memory pressure in Trino by configuring session properties for exchange compression and task parallelism. Adjusting these settings minimizes expensive repartitioning and alleviates bottlenecks during distributed query execution.

How does dynamic filtering work in Trino query optimization?

Dynamic filtering in Trino improves query optimization by generating runtime filters from join operations to reduce scanned data. This mechanism prevents unnecessary reads in partitioned joins by pruning data before the exchange occurs.

When should I use broadcast joins instead of partitioned joins in Trino?

Use broadcast joins in Trino for smaller tables to avoid shuffling, while partitioned joins handle larger datasets. Choosing the correct join strategy through execution plan analysis minimizes data movement and optimizes cross-catalog performance.