---
title: "Shopify's Path to a Faster Trino Query Execution: Custom Verification, Benchmarking, and Profiling Tooling"
description: "Shopify's Data Reliability team built a lightweight Python library on trino-python-client to orchestrate Trino queries, with three uses: PyTest-based verification suites, TPC-DS benchmarking across scale factors, and profiling through traffic generation and query replay."
url: "https://swe.quest/articles/shopify-s-path-to-a-faster-trino-query-execution-custom-verification-2b306664a492e288"
canonical: "https://shopify.engineering/faster-trino-query-execution-verification-benchmarking-profiling"
source: "Shopify Engineering"
published: "2021-10-27"
difficulty: "medium"
kind: "Case study"
reading_minutes: 12
tags: ["query-engines","testing","performance","python","deployment"]
---

# Shopify's Path to a Faster Trino Query Execution: Custom Verification, Benchmarking, and Profiling Tooling

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2021-10-27, 12 min read, Case study. Original: [https://shopify.engineering/faster-trino-query-execution-verification-benchmarking-profiling](https://shopify.engineering/faster-trino-query-execution-verification-benchmarking-profiling)

## Summary

Shopify's Data Reliability team built a lightweight Python library on trino-python-client to orchestrate Trino queries, with three uses: PyTest-based verification suites, TPC-DS benchmarking across scale factors, and profiling through traffic generation and query replay. Verification tests use fixtures and marks (correctness, performance, production\_only), and a multi\_cluster pattern compares a candidate cluster against a standby control. Background queries discard results so hundreds of parallel queries can stress the cluster without exhausting client memory. This was used to evaluate storage caching and Kubernetes horizontal pod autoscaling. The tooling also helped a Trino upgrade succeed with p95 execution time holding steady, and the team stresses that sound statistics and awareness of environment differences are critical for performance testing.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- SQL query engines ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- PyTest fixtures
- distributed clusters basics

## Keywords

Trino, PyTest, TPC-DS, trino-python-client, Kubernetes HPA

## Related posts

- [Shopify's Path to a Faster Trino Query Execution: Infrastructure](https://swe.quest/articles/shopify-s-path-to-a-faster-trino-query-execution-infrastructure-049ef695613ce2a3.md): Shopify Engineering · 2021-07-09 · Medium · 12 min read · Query engines, Performance engineering, Analytics & OLAP, Java & JVM, Kubernetes
  Shopify scaled its Trino interactive query infrastructure on GKE by moving experiment queries to a dedicated cluster via Trino Gateway header routing and capping hardConcurrencyLimit at 60 to relieve coordinator lock contention on the resource group.
- [Finding performance wins in our own traces with a coding agent](https://swe.quest/articles/finding-performance-wins-in-our-own-traces-with-a-coding-agent-884170e809905d07.md): Sentry · 2026-11-03 · Medium · 6 min read · Performance engineering, PostgreSQL, AI for coding, Observability, Python
  Pairing a coding agent with the Sentry MCP over Sentry's own production traces surfaced dozens of small backend fixes that together removed hundreds of millions of queries a week.
- [CockroachDB Redefines Database Performance with Real-World Testing](https://swe.quest/articles/cockroachdb-redefines-database-performance-with-real-world-testing-c9cd765cf1dfea56.md): Cockroach Labs · 2025-05-29 · Hard · 5 min read · Distributed databases, Performance engineering, Resilience, Databases, Chaos engineering
  Cockroach Labs argues that traditional benchmarks like TPC-C, designed in 1992, measure peak throughput in pristine lab conditions and end the test once a power pull disrupts steady state, so they say nothing about behavior during failures, maintenance or recovery.
- [How we stress test and benchmark CockroachDB for global scale](https://swe.quest/articles/how-we-stress-test-and-benchmark-cockroachdb-for-global-scale-c91349f449ee5881.md): Cockroach Labs · 2024-01-25 · Easy · 8 min read · Distributed databases, Performance engineering, Scaling, Testing
  CockroachDB is exercised on a regular cadence of daily, weekly and per-release benchmarks, plus ad hoc and customer-partnered tests, mainly TPC-C, TPC-E and a YCSB-like KV workload.
- [PostgresBench: A Reproducible Benchmark for Postgres Services](https://swe.quest/articles/postgresbench-a-reproducible-benchmark-for-postgres-services-3a30213211ea6b71.md): ClickHouse · 2026-04-02 · Medium · 9 min read · PostgreSQL, Performance engineering, Storage systems, Cloud platforms
  PostgresBench is an open, reproducible benchmark for managed Postgres services built on pgbench's TPC-B-like workload (256 clients, 16 threads, 10-minute runs, three runs each) at ~100 GB and ~500 GB scale factors, with default configs, HA disabled and all services in us-east-2.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
