Re: Index doesn't appear to be working.

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: Index doesn't appear to be working.
Дата
Msg-id 3C876F9D.6F3DA3B9@fourpalms.org
обсуждение исходный текст
Ответ на Index doesn't appear to be working.  ("John Oakes" <john@networkproductions.net>)
Список pgsql-general
> and it tells me:
> Seq Scan on one (cost=0.00..263.02 rows=5613 width=56)
> Shouldn't it tell me
> Index Scan using one_passfail_idx on one?

Only if most of the students are failing ;)

Since most entries in this table are likely to be 'P', the optimizer
correctly concludes that it would be faster to sequentially scan the
table for rows. This is likely to be the optimizer choice for any
two-value column.

If the table has only a few rows (as might be true for a single class or
for a test dataset) then the optimizer will never choose an index scan.

If the table has more than a few hundred rows then you might get an
index scan if you search for students who are failing (again, assuming
that most are not). Make sure that you "vacuum analyze" after populating
the table to get correct statistics.

                      - Thomas

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

Предыдущее
От: Hubert Palme
Дата:
Сообщение: PL/pgSQL Syntax Problem
Следующее
От: "Randy Widell"
Дата:
Сообщение: PostgreSQL under Cygwin...