public inbox for [email protected]
help / color / mirror / Atom feedFrom: Greg Sabino Mullane <[email protected]>
To: yudhi s <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Query performance issue
Date: Tue, 22 Oct 2024 15:01:55 -0400
Message-ID: <CAKAnmmKMzXaUeVg-WLVReCOD-=+8GUq8=Uc7a0jfU6DgzPZ_Yg@mail.gmail.com> (raw)
In-Reply-To: <CAEzWdqdDTPxxzQYJfr_RdJTtLx-kNnc__z8f9nB25wVQuKzapg@mail.gmail.com>
References: <CAEzWdqfeaLov=e3Dk_wMpzh0yWhGcVJhundmL=QL1X_KqG_Jfw@mail.gmail.com>
<[email protected]>
<CAEzWdqdDTPxxzQYJfr_RdJTtLx-kNnc__z8f9nB25wVQuKzapg@mail.gmail.com>
To be frank, there is so much wrong with this query that it is hard to know
where to start. But a few top items:
* Make sure all of the tables involved have been analyzed. You might want
to bump default_statistics_target up and see if that helps.
* As mentioned already, increase work_mem, as you have things spilling to
disk (e.g. external merge Disk: 36280kB)
* Don't use the "FROM table1, table2, table3" syntax but use "FROM table1
JOIN table2 ON (...) JOIN table3 ON (...)
* Try not to use subselects. Things like WHERE x IN (SELECT ...) are
expensive and hard to optimize.
* You have useless GROUP BY clauses in there. Remove to simplify the query
* There is no LIMIT. Does the client really need all 135,214 rows?
Cheers,
Greg
view thread (9+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Query performance issue
In-Reply-To: <CAKAnmmKMzXaUeVg-WLVReCOD-=+8GUq8=Uc7a0jfU6DgzPZ_Yg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox