Home / Companies / Mergify / Blog / Post Details
Content Deep Dive

On LATERAL Joins

Blog post from Mergify

Post Details
Company
Date Published
Author
Rémy Duthu
Word Count
964
Company Posts That Month
2
Language
English
Hacker News Points
-
Post removed?
No
Summary

A new API endpoint at Mergify encountered performance issues when deployed to production, timing out due to inefficient SQL queries. Initially, a naive approach involved a subquery that scanned 660,000 rows to map SHAs to pull requests, which significantly slowed down the system as it constructed a comprehensive SHA-to-pull-request mapping before applying selective filters. This inefficiency was rectified by using a LATERAL JOIN, which allowed for selective filters to be applied first, drastically reducing the number of rows processed. By performing an indexed lookup for each row in the test metrics rather than a full table scan, the response time improved by a factor of 1000, demonstrating the impact of join order on query performance in PostgreSQL.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.