Re: INSERT/UPDATE statements sometimes choosing not to use PK index?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: INSERT/UPDATE statements sometimes choosing not to use PK index?
Дата
Msg-id 32040.1383054311@sss.pgh.pa.us
обсуждение исходный текст
Ответ на INSERT/UPDATE statements sometimes choosing not to use PK index?  (Matt <bsg075@gmail.com>)
Ответы Re: INSERT/UPDATE statements sometimes choosing not to use PK index?  (Matt <bsg075@gmail.com>)
Список pgsql-general
Matt <bsg075@gmail.com> writes:
> In most cases, EXPLAIN and runtime tell me the index is utilized. However,
> sometime on back to back runs (5 minute intervals) the runtime explodes and
> EXPLAIN shows me that the PK index is not used, as both the staging table
> and destination table a sequentially scanned.

You haven't explained what you do with the "staging table", but maybe you
need to ANALYZE it after you've loaded fresh data into it.  The stats for
the main table are presumably somewhat stable, but the stats for the
staging table maybe not.  The apparent correlation to consecutive runs
lends some support to this theory, as that would reduce the time window
for auto-ANALYZE to fix it for you.

            regards, tom lane


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

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: json datatype and table bloat?
Следующее
От: Rahila Syed
Дата:
Сообщение: Increasing CPU usage of PostgreSQL