reducing number of ANDs speeds up query

Поиск
Список
Период
Сортировка
Искать
От
T. E. Lawrence
Тема
reducing number of ANDs speeds up query
Дата
Msg-id
A956D05B-BE04-4F02-B4C6-9EED88E885ED@icloud.com
Список
Дерево обсуждения
reducing number of ANDs speeds up query "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query Eduardo Morras <emorrasg@yahoo.es>
Re: reducing number of ANDs speeds up query "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query Tony Theodore <tony.theodore@gmail.com>
Re: reducing number of ANDs speeds up query Amit kapila <amit.kapila@huawei.com>
Re: reducing number of ANDs speeds up query "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query Alban Hertroys <haramrae@gmail.com>
Re: reducing number of ANDs speeds up query "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query Alban Hertroys <haramrae@gmail.com>
Re: reducing number of ANDs speeds up query RESOLVED "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query RESOLVED Jeff Janes <jeff.janes@gmail.com>
Re: reducing number of ANDs speeds up query RESOLVED "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query RESOLVED Tom Lane <tgl@sss.pgh.pa.us>
Re: reducing number of ANDs speeds up query RESOLVED "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query RESOLVED Jeff Janes <jeff.janes@gmail.com>
Re: reducing number of ANDs speeds up query RESOLVED "T. E. Lawrence" <t.e.lawrence@icloud.com>
Re: reducing number of ANDs speeds up query RESOLVED Eduardo Morras <emorrasg@yahoo.es>
Hello,

I have a pretty standard query with two tables:

SELECT table_a.id FROM table_a a, table_b b WHERE ... AND ... AND b.value=...;

With the last "AND b.value=..." the query is extremely slow (did not wait for it to end, but more than a minute), because the value column is not indexed (contains items longer than 8K).

However the previous conditions "WHERE ... AND ... AND" should have already reduced the candidate rows to just a few (table_b contains over 50m rows). And indeed, removing the last "AND b.value=..." speeds the query to just a millisecond.

Is there a way to instruct PostgreSQL to do first the initial "WHERE ... AND ... AND" and then the last "AND b.value=..." on the (very small) result?

Thank you and kind regards,
T.

В списке pgsql-general по дате отправления
От: Bruce Momjian
Дата:
Сообщение: Re: Libpq and multithreading
От: Rob Sargentg
Дата:
FAQ