Re: Weird CASE WHEN behaviour causing query to be suddenly very slow

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Weird CASE WHEN behaviour causing query to be suddenly very slow
Дата
Msg-id CAKFQuwYTKZT7CyWEn1qorQzcEh2=O-AaEQTKyH7QuD1s7v_Bhw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Weird CASE WHEN behaviour causing query to be suddenly very slow  ("Kevin Viraud" <kevin.viraud@rocket-internet.de>)
Список pgsql-performance


On Tue, Mar 31, 2015 at 8:58 AM, Kevin Viraud <kevin.viraud@rocket-internet.de> wrote:
Touche ! Thanks a lot.

Looking more at the data yes it goes very often to ELSE Clause.  And
therefore reaching  the MAX_CACHED_RES.

In there anyway to increase that value  ?

Basically, I have several tables containing millions of rows and let say 5
columns. Those five columns, depending of their  combination give me a 6th
value.
We have complex patterns to match and using simple LIKE / EQUAL and so on
wouldn't be enough. This can be applied to N number of table so we
refactored this process into a function that we can use in the SELECT
statement, by giving only the 5 values each time.

I wouldn't mind using a table and mapping it through a join  if it were for
my own use.
But the final query has to be readable and usable for almost-non-initiated
SQL user... So using a function with encapsulated case when seemed to be a
good idea and so far worked nicely.

But we might consider changing it if we have no other choice...

Regards,

Kevin


​Thoughts...​


Rewrite the function in pl/perl​ and compare performance

​Hierarchy of CASE statements allowing you to reduce the number of possibilities in exchange for manually pre-processing the batches on a significantly less complicated condition probably using only 1 or 2 columns instead of all five.​

​I'm not familiar with the caching constraint or the data so its hard to make more specific suggestions.

David J.​

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Kevin Viraud"
Дата:
Сообщение: Re: Weird CASE WHEN behaviour causing query to be suddenly very slow
Следующее
От: Josh Berkus
Дата:
Сообщение: Some performance testing?