Re: broken join optimization? (8.0)

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: chester c young <chestercyoung(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: broken join optimization? (8.0)
Date: 2005-10-26 02:42:11
Message-ID: 20051026024211.GA98628@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Oct 25, 2005 at 04:56:11PM -0700, chester c young wrote:
> in php (for example) it's frequently nice to get the structure of a
> table without any data, ie, pull a single row with each attribute's
> value is null. I use the query (dual is a table of one row ala
> Oracle):
>
> select m.* from dual
> left join mytable m on( false );

Have you considered "SELECT * FROM mytable LIMIT 0"? APIs typically
allow you to find out the row structure even if no rows were returned.
In recent versions of PHP, for example, you can use pg_num_fields(),
pg_field_name(), pg_field_type(), etc., or perhaps the experimental
pg_meta_data().

> this works every time, but if mytable is big, then takes a long time.

I see the same behavior in the latest 8.1beta code. Maybe one of
the developers will comment on whether optimizing that is a simple
change, a difficult change, not worth changing because few people
find a use for it, or a behavior that can't be changed because of
something we're not considering.

--
Michael Fuhr

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-10-26 02:51:51 Re: backend error
Previous Message Bruce Momjian 2005-10-26 01:38:15 Re: ?Equiv to oracle (ENABLE|DISABLE) (CONSTRAINT|TRIGGER) statements?