Possible improvement

Поиск
Список
Период
Сортировка
От Paul van der Linden
Тема Possible improvement
Дата
Msg-id CAEC-EqBVFGXBG2xH-U+LOXPwiu0bwqoPj=daLmmNvNZRneW+5A@mail.gmail.com
обсуждение исходный текст
Ответы Re: Possible improvement  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-general
Hi,

Don't know if this already came up earlier but I have an idea for improvement.

If I have a query like:

SELECT * FROM (
SELECT
  CASE
      WHEN field='value1' THEN 1
      WHEN field='value2' THEN 2
  END AS category
FROM table1
) AS foo
WHERE category=1

doesn't use the index on field, while technically it could do that.
Is it hard to implement drilling down the constant in the WHERE to within the CASE?
This is especially convenient with views (inner SELECT) where the category is some complex list of possibilities and you want to filter (outer SELECT) on specific categories
I know a different solution could be creating an index on that CASE but (especially if you're experimenting a bit) can be quite cumbersome to synchronize that with the actual query.

Is this something that could be put on some wishlist? If so where are the most looked at ones?

Paul

P.S. In replies please use reply to all...

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

Предыдущее
От: Samuel Smith
Дата:
Сообщение: Monitoring for long running transactions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Index no longer being used, destroying and recreating it restores use.