From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marten Verhoeven <m.verhoeven@van-beek.nl>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow performance with left outer join
Date: Mon, 21 Jan 2008 11:55:55 -0500
Message-ID: <8283.1200934555@sss.pgh.pa.us> (raw)
In-Reply-To: <D4E656958EEB52498883B7906D789CD54018EF@alpha2>
References: <D4E656958EEB52498883B7906D789CD54018EF@alpha2>
"Marten Verhoeven" <m.verhoeven@van-beek.nl> writes:
> This is the query analysis:
> Nested Loop Left Join (cost=1796.69..3327.98 rows=5587 width=516)
> Join Filter: (fpuarticle.a_no = fpuarticletext.at_a_no)
> Filter: (strpos(lower((((COALESCE(fpuarticle.a_code, ''::character varying))::text || ' '::text) || (COALESCE(fpuarticletext.at_text, ''::character varying))::text)), 'string'::text) > 0)
> -> Seq Scan on fpuarticle (cost=0.00..944.62 rows=16762 width=386)
> -> Materialize (cost=1796.69..1796.70 rows=1 width=130)
> -> Seq Scan on fpuarticletext (cost=0.00..1796.69 rows=1 width=130)
> Filter: ((COALESCE((at_type)::integer, 1) = 1) AND (COALESCE(at_language, 0::numeric) = 0::numeric))
If this is slow, it must be that the scan of fpuarticletext actually
returns many more rows than the single row the planner is expecting.
The reason the estimate is off is probably that the planner cannot make
any useful estimate about those COALESCE expressions. Try rewriting
them in the simpler forms
(at_type = 1 or at_type is null) AND
(at_language = 0 or at_language is null)
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, m.verhoeven@van-beek.nl
Subject: Re: Slow performance with left outer join
In-Reply-To: <8283.1200934555@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