Re: Very slow catalog query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Very slow catalog query
Дата
Msg-id 14972.1206984445@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Very slow catalog query  ("Just Someone" <just.some@gmail.com>)
Ответы Re: Very slow catalog query  ("Just Someone" <just.some@gmail.com>)
Список pgsql-general
"Just Someone" <just.some@gmail.com> writes:
> Here is the result of explain analyze (though this one took 1500ms and
> not 169000):

Well, it's hard to be sure what the problem is when you're not showing
us a problem case ...  but I notice that this indexscan is estimated
awfully high:

>                            ->  Index Scan using
> pg_depend_reference_index on pg_depend dep  (cost=0.00..64942.17
> rows=247 width=12) (actual time=396.542..1547.172 rows=22 loops=1)
>                                  Index Cond: (refobjid = 30375069::oid)

The reason is not far to seek: the scan is checking only the second
index key, meaning that it has to scan the entire index.  (I am
surprised it didn't use a seqscan instead.  Are you using enable_seqscan
= off?  Not a great idea.)  Since you know you are looking for a table,
you could improve matters by adding a constraint on refclassid:

    dep.refclassid = 'pg_class'::regclass

            regards, tom lane

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

Предыдущее
От: "x asasaxax"
Дата:
Сообщение: Re: Primary Key with serial
Следующее
От: "Andrej Ricnik-Bay"
Дата:
Сообщение: Re: Schema design question