← Graph

LATERAL Joins Rails Performance Lightning Talk

talk 6 connections

Wroclove.rb 2018 lightning talk replicating the heavy Rails products/reviews example from an earlier talk. Starts from a 300-ms products#index rendering 100 products with per-row avg-rating computation — two queries per row yield the slowness. Compares three SQL approaches on a dataset of 2,000 products, 2,000 users and 300,000 reviews: (1) classic SQL with AVG + JOIN + GROUP BY + ORDER BY + LIMIT 10 → ~140 ms; (2) Common Table Expression (Postgres ≥ 8.4) pre-computing averages → ~99 ms; (3) LATERAL join (Postgres ≥ 9.3) correlating a subquery per product → similar time without filtering but dramatic gains with filtering (classic ~47 ms, CTE unchanged, LATERAL ~5 ms). Final page load drops to 37 ms.

type
lightning-talk
talk LATERAL Joins Rails Performance Lightning Talk
about
LATERAL join concept
Shows LATERAL joins delivering the biggest speedup with filtering.
talk LATERAL Joins Rails Performance Lightning Talk
about
Compares CTE against classic SQL and LATERAL for top-rated products query.
talk LATERAL Joins Rails Performance Lightning Talk
about
PostgreSQL tool
All three optimized queries target PostgreSQL features (≥ 8.4 for CTE, ≥ 9.3 for LATERAL).
from_talk
LATERAL Joins Rails Performance Lightning Talk talk
Key insight derived from the benchmarking in the talk.
talk LATERAL Joins Rails Performance Lightning Talk
presented_at
Lightning talk delivered at wroclove.rb 2018.
talk LATERAL Joins Rails Performance Lightning Talk
related_to
Replicates the heavy-Rails products/reviews example from the earlier day-one performance talk and applies SQL-level optimization instead of caching.

Provenance

Read by
13 extractions