Search Postgresql Archives

Re: Query optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux