Re: Plans for ON DELETE CASCADE? Which index is used, if at all?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Plans for ON DELETE CASCADE? Which index is used, if at all?
Date: 2023-03-28 14:22:35
Message-ID: 7b756f27-fcd6-44d9-f61b-f86355327a90@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/28/23 06:55, Dominique Devienne wrote:
> On Tue, Mar 28, 2023 at 3:23 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>> wrote:
>
> Dominique Devienne <ddevienne(at)gmail(dot)com
> <mailto:ddevienne(at)gmail(dot)com>> writes:
> > Hi. Given the classical parent/child schema below, with an ON DELETE
> > CASCADE FK constraint, I'd like to know which index is used (if
> any) to
> > delete child rows affected by the CASCADE.
>
> > But explain (analyze) does not give me that.
>
> Yeah, it will just report the time spent in the FK triggers,
> not what they were doing exactly.
>
> IIRC, you can see the CASCADE operations with contrib/auto_explain,
> if you enable auto_explain.log_nested_statements.
>
>
> Thanks. Looks like this won't be easily available to me :(. --DD

It is part of the community contrib modules:

https://www.postgresql.org/docs/current/auto-explain.html

So install via whatever package system you are using. Or if building
from source build in the contrib/ directory.

>
> dd=> select * from pg_available_extensions where name like '%auto%';
>   name   | default_version | installed_version |                comment
> ---------+-----------------+-------------------+---------------------------------------
>  autoinc | 1.0             |                   | functions for
> autoincrementing fields
> (1 row)
>
> dd=> select * from pg_available_extensions where name like '%explain%';
>  name | default_version | installed_version | comment
> ------+-----------------+-------------------+---------
> (0 rows)

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sebastien Flaesch 2023-03-28 14:23:06 Re: Using CTID system column as a "temporary" primary key
Previous Message Dominique Devienne 2023-03-28 13:55:59 Re: Plans for ON DELETE CASCADE? Which index is used, if at all?