Re: WITH AS vs subselect was: count (DISTINCT expression [ , ... ] ) and documentation

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>, pgsql-general(at)postgresql(dot)org
Subject: Re: WITH AS vs subselect was: count (DISTINCT expression [ , ... ] ) and documentation
Date: 2008-12-27 07:10:43
Message-ID: 20081227071043.GC3793@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Dec 26, 2008 at 07:13:48PM -0500, Tom Lane wrote:
> Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> writes:
> >>> David Fetter <david(at)fetter(dot)org> wrote:
> >>>> In 8.4, you'll be able to do:
>
> >>>> WITH d AS (
> >>>> SELECT DISTINCT c1, c2 FROM table1
> >>>> )
> >>>> SELECT count(*) FROM d;
>
> >>> Nice, but what will be the difference from
> >>> select count(*) from (select distinct c1, c2 from t);
> >>> ?
> >>> Optimisation?
>
> >> None especially.
>
> > So what would be the advantage compared to subselect?
>
> None, David just has WITH on the brain ;-)

LOL!

You're only saying that because it's true ;)

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2008-12-27 09:14:15 Re: "disappearing" rows in temp table, in recursing trigger
Previous Message J Ottery 2008-12-27 05:47:39 Bind message has 6 results formats but query has 5 columns