From: Tom Lane <tgl@sss.pgh.pa.us>
To: henk de wit <henk53602@hotmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Redundant sub query triggers slow nested loop left join
Date: Sun, 22 Apr 2007 16:42:33 -0400
Message-ID: <10143.1177274553@sss.pgh.pa.us> (raw)
In-Reply-To: <BAY106-F1ED861D02B3FF316BFF68F5540@phx.gbl>
References: <BAY106-F1ED861D02B3FF316BFF68F5540@phx.gbl>
"henk de wit" <henk53602@hotmail.com> writes:
> I understand the above looks like a complicated mess, but would you
> have any pointers of what I could possibly do next to force a better plan?
Taking a closer look, it seems the problem is the underestimation of the
number of rows resulting from this relation scan:
> -> Bitmap Heap Scan on
> banners_links (cost=11.43..954.03 rows=2 width=73) (actual
> time=0.128..1.069 rows=359 loops=1)
> Recheck Cond: (merchant_id = 5631)
> Filter: ((status)::text = '0'::text)
> -> Bitmap Index Scan on
> banners_links_merchant_id_idx (cost=0.00..11.43 rows=424 width=0) (actual
> time=0.089..0.089 rows=424 loops=1)
> Index Cond: (merchant_id = 5631)
You might be able to improve matters by increasing the statistics target
for this table. I have a bad feeling though that the problem may be
lack of cross-column statistics --- the thing is evidently assuming
that only about 1 in 200 rows have status = '0', which might be accurate
as a global average but not for this particular merchant. What exactly
is the relationship between status and merchant_id, anyway?
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, henk53602@hotmail.com
Subject: Re: Redundant sub query triggers slow nested loop left join
In-Reply-To: <10143.1177274553@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