Re: database not using indexes

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: database not using indexes
Дата
Msg-id 4EBB39BA.5090102@ringerc.id.au
обсуждение исходный текст
Ответ на Re: database not using indexes  ("Ruslan A. Bondar" <fsat@list.ru>)
Список pgsql-admin
On 09/11/11 23:58, Ruslan A. Bondar wrote:
>
> Why have you decided it isn't using indexes?
> If index exists - postgres will use it.

Actually that's not necessarily the case.

PostgreSQL will only use an index if (a) the index can be used for that
kind of query and (b) using the index will be faster than doing a
sequential scan.

If a query requires all the data in a table, PostgreSQL is quite likely
to do a sequential scan of the table, because it'll need to read every
block anyway. Reading just the table (without reading the index) in
order is much faster than reading the index then doing semi-random reads
of the table.

Additionally, not all indexes can be used for all operations. For
example, a LIKE query with a prefix wildcard eg "%FRED" cannot use a
btree index, so any btree index on the searched field will be ignored.

--
Craig Ringer

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: How to deal with corrupted database?
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: database not using indexes