[PERFORM] Re: Fwd: Slow query from ~7M rows, joined to two tables of ~100 rowseach

Поиск
Список
Период
Сортировка
От Karl Czajkowski
Тема [PERFORM] Re: Fwd: Slow query from ~7M rows, joined to two tables of ~100 rowseach
Дата
Msg-id 20170626170120.GB27236@moraine.isi.edu
обсуждение исходный текст
Ответ на Re: [PERFORM] Fwd: Slow query from ~7M rows, joined to two tables of ~100 rows each  (Chris Wilson <chris+postgresql@qwirx.com>)
Список pgsql-performance
On Jun 26, Chris Wilson modulated:
> ...
>     In your case, the equivalent hack would be to compile the small
>     dimension tables into big CASE statements I suppose...
>
>
> Nice idea! I tried this but unfortunately it made the query 16 seconds
> slower (up to 22 seconds) instead of faster.

Other possible rewrites to try instead of joins:

  -- replace the case statement with a scalar subquery

  -- replace the case statement with a stored procedure wrapping that scalar subquery
     and declare the procedure as STABLE or even IMMUTABLE

These are shots in the dark, but seem easy enough to experiment with and might
behave differently if the query planner realizes it can cache results for
repeated use of the same ~100 input values.


Karl



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

Предыдущее
От: Chris Wilson
Дата:
Сообщение: Re: [PERFORM] Fwd: Slow query from ~7M rows, joined to two tables of ~100 rows each
Следующее
От: Karl Czajkowski
Дата:
Сообщение: [PERFORM] Re: Fwd: Slow query from ~7M rows, joined to two tables of ~100 rowseach