Seeing foreign key lookups in explain output

From: Vincent de Phily <vincent(dot)dephily(at)mobile-devices(dot)fr>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Seeing foreign key lookups in explain output
Date: 2011-09-20 12:35:14
Message-ID: 3798971.mRNc5JcYXj@moltowork
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi list,

an explain analyze wish :

create table t1(id serial primary key);
create table t2(id serial primary key,
ref integer references t1(id) on delete cascade);
...insert many rows in both tables...
explain delete from t1 where id < 10000;
...
The explain output will tell me it's using the index on t1's id, but it tells
me nothing about the seqscan that happens on t2 (because I forgot to add an
index on t2.ref).

It isn't the first time I get bitten by this, and I bet I'm not the only one.
The explain tells me everything will work fast, but reallity is 100 times
slower. Is there a way I can extend explain output to show the rest of the
work done behind the scene ? Fixing that performance issue is easy once you
see it, but most people will just look at the explain output and erroneously
conclude "it's as good as it gets".

--
Vincent de Phily

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reid Thompson 2011-09-20 12:37:22 Is libpq version indifferent? I.E. can 8.3.x compiled binaries run without issue against a 9.1 backend, or are clients required to be re-compiled against the 9.1 libpq
Previous Message Leonardo Francalanci 2011-09-20 11:54:56 cache oblivious indexes (tokudb, fractal indexes)