how can i show constraint checks in explain ?

Поиск
Список
Период
Сортировка
Искать

how can i show constraint checks in explain ?

От:
Jonathan Vanasco <postgres@2xlp.com>
Дата:

I've got a DELETE query that takes ~2 seconds to process

The reasoning is simple -- its doing referential checks, to make sure  
that I'm not deleting  a valid fkey , as several tables fkey on that  
one.

The issue i'm running into is obvious: this should not take 2  
seconds.  anything that fkeys should have that column as an index  
already.  very likely, one doesn't because  I messed up when I  
created the dable.

However-- explain doesn't pull in the planner's scanning info in  
regards to the fkey constraints.  is there any function or argument  
that will ?

i'd like to know which tables are getting what must be a sequential  
scan and not an index scan, so I can reindex properly.


Re: how can i show constraint checks in explain ?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jonathan Vanasco  writes:
> However-- explain doesn't pull in the planner's scanning info in  
> regards to the fkey constraints.  is there any function or argument  
> that will ?

Not directly --- but in reasonably recent PG versions, EXPLAIN ANALYZE
shows the runtime for trigger functions, including fkey triggers.
That would let you figure out which fkey is the problem.

			regards, tom lane
FAQ