Sitemap

PostgreSQL 17 vs 18: The Hidden Upgrade That Makes Your Queries Run Instantly

4 min readOct 29, 2025

What if your database suddenly became five times faster — and you didn’t change a single line of code?

On 25 September 2025 the PostgreSQL 18 release notes officially listed the optimizer enhancement: “Automatically remove some unnecessary table self-joins”. PostgreSQL+1 .

No tweaks. No indexes. No magic.
Just PostgreSQL 18.

Press enter or click to view image in full size

So what exactly happened?
The answer lies in a quiet little optimization called Self-Join Elimination — a feature that’s been in the making for seven years.

🧠 Why Self-Join Elimination Matters

Most of us don’t write raw SQL anymore.
We use ORMs like Django, Hibernate, or Entity Framework to save time and keep our code clean.

The problem? ORMs often generate extra joins — especially self-joins, where a table is joined to itself unnecessarily.

Here’s a simple example:

SELECT o.order_id, o.total_amount, c.customer_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
WHERE o.order_date > '2024-01-01'
AND c.customer_id IN (
SELECT c2.customer_id
FROM customers c2
WHERE c2.country = 'USA'…

--

--

Rizqi Mulki

Written by Rizqi Mulki

Backend dev with 14 years of experience. Writes on scalability, secure, high-performance systems. AI-assisted content reviewed for accuracy

No responses yet