Re: Or selection on index versus union

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Or selection on index versus union
Дата
Msg-id 20051004210838.GA72829@winnie.fuhr.org
обсуждение исходный текст
Ответ на Or selection on index versus union  (han.holl@informationslogik.nl)
Ответы Re: Or selection on index versus union  (han.holl@informationslogik.nl)
Список pgsql-general
On Tue, Oct 04, 2005 at 09:32:41PM +0200, han.holl@informationslogik.nl wrote:
> I've got a table with an index, let's call it fase.
>
> The following query is fine: 'select something from table where fase = '1';
>
> However, this is disastrously slow:
> select something from table where fase = '1' or fase = '2';

Could we see some EXPLAIN ANALYZE output?  What version of PostgreSQL
are you using?  Have you run VACUUM ANALYZE on the table to remove
dead tuples and update the statistics?  Have you considered clustering
the table on fase's index?

It might be useful to see the output of the following queries,
assuming the table name is foo:

SET enable_seqscan TO on;
SET enable_indexscan TO off;
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1';
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '2';
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1' OR fase = '2';

SET enable_seqscan TO off;
SET enable_indexscan TO on;
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1';
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '2';
EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1' OR fase = '2';

SHOW random_page_cost;
SHOW effective_cache_size;
SELECT version();

\x
SELECT * FROM pg_stats WHERE tablename = 'foo' AND attname = 'fase';

BTW, pgsql-performance is a list dedicated to performance issues,
so you might want to ask performance-related questions there.

--
Michael Fuhr

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

Предыдущее
От: Douglas McNaught
Дата:
Сообщение: Re: Isolated transactions?
Следующее
От: han.holl@informationslogik.nl
Дата:
Сообщение: Re: Or selection on index versus union