From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Crate <jimcfl@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Subquery flattening causing sequential scan
Date: Tue, 27 Dec 2011 13:12:46 -0500
Message-ID: <12106.1325009566@sss.pgh.pa.us> (raw)
In-Reply-To: <0E417F76-FE21-4FB5-8132-0C485778A041@gmail.com>
References: <0E417F76-FE21-4FB5-8132-0C485778A041@gmail.com>
Jim Crate <jimcfl@gmail.com> writes:
> My question is why does it do a seq scan when it flattens this
> subquery into a JOIN?
Because it thinks there will be 3783 rows out of the msg scan, which if
true would make your desired nestloop join a serious loser. You need to
see about getting that estimate to be off by less than three orders of
magnitude. Possibly raising the stats target on emsg_messages would
help. I'd also try converting the inner NOT IN into a NOT EXISTS, just
to see if that makes the estimate any better. Using something newer
than 9.0.2 might help too, as we fixed some outer-join estimation bugs a
few months ago.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, jimcfl@gmail.com
Subject: Re: Subquery flattening causing sequential scan
In-Reply-To: <12106.1325009566@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox