pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: chester c young <chestercyoung@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: broken join optimization? (8.0)
Date: Tue, 25 Oct 2005 20:42:11 -0600
Message-ID: <20051026024211.GA98628@winnie.fuhr.org> (raw)
In-Reply-To: <20051025235612.20767.qmail@web54301.mail.yahoo.com>
References: <20051025235612.20767.qmail@web54301.mail.yahoo.com>

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



view thread (7+ messages)  latest in thread

Message-ID: <20051026024211.GA98628@winnie.fuhr.org>
Permalink:  ../20051026024211.GA98628@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20051026024211.GA98628@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, chestercyoung@yahoo.com
  Subject: Re: broken join optimization? (8.0)
  In-Reply-To: <20051026024211.GA98628@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox