Re: planner issue with constraint exclusion

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: planner issue with constraint exclusion
Date: 2008-12-15 20:46:47
Message-ID: 20081215204647.GE26233@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Joshua D. Drake (jd(at)commandprompt(dot)com) wrote:
> On Mon, 2008-12-15 at 14:28 -0500, Tom Lane wrote:
> > "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > > Of the functions the only one that will use constraint_exclusion is the
> > > one that explicitly passes the date value.
> >
> > Since you haven't shown us the constraints you're talking about, or the
> > resulting plans, it's difficult for anyone to guess what's going on.
>
> I am not sure which plans I should show you as they are function plans
> thereby not very useful.

Ideally, do a 'raise notice' with the exact string you're passing to
EXECUTE, and then run an explain on that. Constraint Exclusion
certainly does work when using explain and constants in general. Have
you tried adding an explicit cast, ala:

EXECUTE 'SELECT l.unit_id FROM foo_stats_day lsd, foo51 l WHERE lsd.a_serv_id = l.unit_id AND lsd.a_serv_id = 1 AND day = ''' || temp || '''::date';

Enjoy,

Stephen

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2008-12-15 21:06:15 Re: Sync Rep: First Thoughts on Code
Previous Message Peter Eisentraut 2008-12-15 20:41:10 Re: SQL/MED compatible connection manager