On Wed, 15 Jan 2003, Roman Fail wrote:
I just had new thoughts.
If you make an index on batchdetail(batchid)
does that help?
I realized that it was doing a merge join
to join d and the (t,b,m) combination when it
was expecting 3 rows out of the latter, and
batchid is presumably fairly selective on
the batchdetail table, right? I'd have expected
a nested loop over the id column, but it
doesn't appear you have an index on it in
batchdetail.
Then I realized that batchheader.batchid and
batchdetail.batchid don't even have the same
type, and that's probably something else you'd
need to fix.
> batchheader has 2.6 million records:
> CREATE TABLE public.batchheader (
> batchid int8 DEFAULT nextval('"batchheader_batchid_key"'::text) NOT NULL,
> And here's batchdetail too, just for kicks. 23 million records.
> CREATE TABLE public.batchdetail (
> batchid int4,