public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Durgamahesh Manne <[email protected]>
To: pgsql-general <[email protected]>
Subject: Re: Query optimization
Date: Thu, 13 Mar 2025 20:34:01 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAJCZkoL+DHs0H9enQEg8JXZw=7032zrmFKG8Vx0fup6_wqNpnQ@mail.gmail.com>
References: <CAJCZkoL+DHs0H9enQEg8JXZw=7032zrmFKG8Vx0fup6_wqNpnQ@mail.gmail.com>

On Fri, 2025-03-14 at 00:42 +0530, Durgamahesh Manne wrote:
> This query takes more time than usual for execution 
> 
> How to optimize it in best possible way
> 
> Columns used in this query >> composite index eventhough not running optimally 
> SELECT EXISTS (SELECT Key FROM CACHEKEYS WHERE CacheType = $1 AND TrsId = $2 AND
>                BrandId = $3 AND SportId = $4 AND CompetitionId = $5 AND
>                EventId = $6 AND MarketId = $7 LIMIT ?)

"The best possible way" is hard to say, because an index will have negative
effects on data modification statements.

But for the fastest execution of the query, simply create an index on all the
columns that occur in the WHERE clause.  The order doesn't matter.

And remove that useless LIMIT clause.

Yours,
Laurenz Albe






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]
  Subject: Re: Query optimization
  In-Reply-To: <[email protected]>

* 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