Re: join from array or cursor

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: join from array or cursor
Date: 2009-08-21 15:22:55
Message-ID: 20090821152255.GE5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 21, 2009 at 10:49:52AM -0400, Merlin Moncure wrote:
> On Fri, Aug 21, 2009 at 10:17 AM, Sam Mason<sam(at)samason(dot)me(dot)uk> wrote:
> > CREATE TYPE foo AS ( i int, j int );
> >
> > SELECT (id((SELECT (1,2)::foo))).*;
> >
> > or am I missing something obvious?
>
> I think that what you are bumping in to is that there is no real
> definition of '*' in the query. 've griped about this a few times. If
> type 't' has fields a,b,
>
> select (t).* is expanded to select (t).a, (t).b.

OK, but that's not because of there being no "real definition" of *.
It seems perfectly well defined in the example above as a tuple of two
integers. The thing that causes it to go wrong here is that PG doesn't
know that doing this expansion (as you noted above) can cause the query
to become very expensive. PG should instead arrange that the expression
"t" is run exactly once and reuse the single result for all columns.

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Hopkins 2009-08-21 15:29:48 Re: Out of memory on pg_dump
Previous Message Tom Lane 2009-08-21 15:06:48 Re: Out of memory on pg_dump