Re: PG choosing nested loop for set membership? - Mailing list pgsql-general

From Brian Crowell
Subject Re: PG choosing nested loop for set membership?
Date
Msg-id CAAQkdDrytBz6vSJRxBCvuVckdqwHE7LqgqTRHoXGeTTtgSPJGQ@mail.gmail.com
Whole thread Raw
In response to Re: PG choosing nested loop for set membership?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, Mar 26, 2014 at 11:43 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> In principle I guess we could somehow merge the stats of y and z
> when looking at a "coalesce(y, z)" expression, but I'm not sure
> how that would work exactly.

Yeah, I'm not sure there's anything to fix here, either. Just a
reminder that coalesces in joins are bad.

The only thing I could think was making an exception for the case when
all inputs to coalesce() have one row. I think that's what's happening
here; coalesce selectivity is estimated at less than one, even though
you can't get a cardinality any less than the inputs (they're already
one), so the nested loop sees an estimate that's less than the product
of its inputs. Or that's my guess anyhow.

Thanks for having a look!

--Brian


pgsql-general by date:

Previous
From: Steven Schlansker
Date:
Subject: Re: Trimming transaction logs after extended WAL archive failures
Next
From: Nithya Soman
Date:
Subject: To monitor the number of PostgreSQL database connections?