Re: Index unused with OR?

Поиск
Список
Период
Сортировка
От Olaf Mittelstaedt
Тема Re: Index unused with OR?
Дата
Msg-id 199805141359.PAA04711@gate.va.fh-ulm.de
обсуждение исходный текст
Ответ на Re: [INTERFACES] Index unused with OR?  (Teodorescu Constantin <teo@flex.flex.ro>)
Ответы Re: [INTERFACES] Re: Index unused with OR?  (Teodorescu Constantin <teo@flex.flex.ro>)
Re: [INTERFACES] Re: Index unused with OR?  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Список pgsql-interfaces
> The index is used only if scanning the index is faster than
> scanning the table itself. Trying the index only with a couple of
> records isn't good.

> Try inserting some hundred records inside and VACUUM the database
> after.

Actually, I discovered the problem using a table containg more than
8000 rows, using the latest release 6.3.2.

> When you vacuum the database you are updating the statistics table
> used by the query optimizer. The query optimizer will choose to
> use an index when it found that it worths.

> Not using the index in OR queries was some-time ago a bug in
> PostgreSQL 6.1 if my memory is good. Think that has been solved in
> new releases, am I wrong ?

This is the real database:

w=> select count(*) from p;
count
-----
 8331
(1 row)

w=> vacuum;
VACUUM
w=> explain select * from p where m = 29000;
NOTICE:  QUERY PLAN:

Index Scan on p  (cost=0.00 size=0 width=10)

EXPLAIN
w=> explain select * from p where (m=29000) or (m=30000);
NOTICE: QUERY PLAN:

Seq Scan on p (cost=0.00 size=0 width=10)

EXPLAIN


Regards,
Olaf

--
Olaf Mittelstaedt - IuK - mittelstaedt@fh-ulm.de
Fachhochschule Ulm  Prittwitzstr. 10   89075 Ulm
Tel.: +49 (0)731-502-8220             Fax: -8270

 Ash nazg durbatulûk, ash nazg gimbatul,
  ash nazg thrakatulûk agh burzum-ishi krimpatul.


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

Предыдущее
От: Teodorescu Constantin
Дата:
Сообщение: Re: [INTERFACES] Index unused with OR?
Следующее
От: Manuel Reiter
Дата:
Сообщение: JDBC-driver for postgresql