Re: Joins, Deletes and Indexes

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Joins, Deletes and Indexes
Дата
Msg-id 421C883A.20708@archonet.com
обсуждение исходный текст
Ответ на Re: Joins, Deletes and Indexes  (Butkus_Charles@emc.com)
Список pgsql-performance
Butkus_Charles@emc.com wrote:
>
> The cluster table only has 11 rows, so I'm not sure an index would
> help.  The sensorreport table has 15,000,000 rows so that's why I've
> got the index there.

Ah - only 11?

>>>on the foreign key from sensortable.
>>>Again, is there any way to get the delete to use the
>>>idx_sensorreport_clusterid index?
>>
>>No, because this is the cluster table, not sensorreport :-)
>
> True, but the foreign key constraint on the sensorreport table forces
> Postgres to check if there are any sensorreport's that are currently
> using this cluster before allowing the cluster to be deleted.

If you only have 11 distinct values in the large table then it's
debatable whether it's always quicker to use the index. Since your first
example (clusterid = 25000114) returned so few rows, I'm guessing that
some other values represent a sizeable percentage of the table. That'd
explain the difference between PG's estimates and the actual number of
matching rows.

You can try "SET enable_seqscan =false;" before running the query and
see whether using the index helps things.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Butkus_Charles@emc.com
Дата:
Сообщение: Re: Joins, Deletes and Indexes
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: PostgreSQL is extremely slow on Windows