Re: Slow query fixed by replacing equality with a nested query

From: Valentin Janeiko <val(dot)janeiko(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow query fixed by replacing equality with a nested query
Date: 2022-01-24 13:22:41
Message-ID: CAPhGPA7iCqCxbvycaVWr3qjOf5gGv68f4zYwA-hWeUJVQSnreQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I have rewritten the query using JOINs. I had to make one of them a
FULL JOIN, but otherwise JOINs seem like a good idea.
I have added the new query to the (same) gist:
https://gist.github.com/valeneiko/89f8cbe26db7ca2651b47524462b5d18#file-queryoptimized-sql
The query plan is much better with just a few small index scans which
completes in under a millisecond: https://explain.depesz.com/s/vBdG

Thank you for your help. Let me know if you have any other suggestions.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Michael Lewis 2022-01-24 17:50:40 Re: Slow query fixed by replacing equality with a nested query
Previous Message val.janeiko 2022-01-21 11:37:54 RE: Slow query fixed by replacing equality with a nested query