Re: Incorrect index being used

Поиск
Список
Период
Сортировка
От BladeOfLight16
Тема Re: Incorrect index being used
Дата
Msg-id CA+=1U=U+jDm83azDBO1kyHT=SEVwr5h5j1WaiKXTY4CoepfXUg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Incorrect index being used  (Jesse Long <jpl@unknown.za.net>)
Ответы Re: Incorrect index being used  (Jesse Long <jpl@unknown.za.net>)
Re: Incorrect index being used  (Jesse Long <jpl@iso-8859-1.za.net>)
Список pgsql-general
On Fri, Oct 11, 2013 at 9:32 AM, Jesse Long <jpl@unknown.za.net> wrote:
explain select * from archive_document_index where node_id = 29 and value = 'BSH70002152';
                                                        QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------
 Index Scan using archive_document_index_node_id_value_idx on archive_document_index  (cost=0.57..36.13 rows=14 width=33)
   Index Cond: ((node_id = 29) AND ((value)::text = 'BSH70002152'::text))
(2 rows)

I believe that this is what Tom is suggesting:

SELECT *
FROM ARCHIVE_DOCUMENT AS ad
WHERE ad.NODE_ID = 29
  AND ad.ARCHIVE_DATE >= '2013-07-08 18:28:00'
  AND EXISTS (SELECT *
              FROM ARCHIVE_DOCUMENT_INDEX AS adi
              WHERE adi.ARCHIVE_ID = ad.ID
                AND adi.NODE_ID = ad.NODE_ID
                AND (adi.VALUE = 'BSH70002152' OR adi.VALUE = 'TC212592')
             )
ORDER BY ad.ARCHIVE_DATE DESC
LIMIT 10;


Forgive my changing of the aliases. I found names like r0 difficult to interpret easily.

This is a much simpler query since it only requires one subselect, and I believe Tom is suggesting that this query may be able to make use of the index or at least find some more efficient plan. How does this perform?

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

Предыдущее
От: Sergey Konoplev
Дата:
Сообщение: Re: postgres 9.0.4 configuration and performance issue
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: declare constraint as valid