X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A168EDAED4 for ; Tue, 25 Oct 2005 23:42:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71867-04 for ; Wed, 26 Oct 2005 02:42:09 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 3B60EDA924 for ; Tue, 25 Oct 2005 23:42:11 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j9Q2gCSf003639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 25 Oct 2005 20:42:15 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id j9Q2gCvv098710; Tue, 25 Oct 2005 20:42:12 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id j9Q2gBcx098709; Tue, 25 Oct 2005 20:42:11 -0600 (MDT) (envelope-from mfuhr) Date: Tue, 25 Oct 2005 20:42:11 -0600 From: Michael Fuhr To: chester c young Cc: pgsql-sql@postgresql.org Subject: Re: broken join optimization? (8.0) Message-ID: <20051026024211.GA98628@winnie.fuhr.org> References: <20051025235612.20767.qmail@web54301.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051025235612.20767.qmail@web54301.mail.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/299 X-Sequence-Number: 23152 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