X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FC0852A96 for ; Sat, 30 Jul 2005 01:16:41 -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 40641-01 for ; Sat, 30 Jul 2005 04:16:33 +0000 (GMT) Received: from pow.actarg.com (host25.actarg.com [209.180.91.25]) by svr1.postgresql.org (Postfix) with ESMTP id 5E3ED529A5 for ; Sat, 30 Jul 2005 01:16:32 -0300 (ADT) Received: from [192.168.5.50] (bateman.cc [65.73.113.56]) (authenticated bits=0) by pow.actarg.com (8.13.1/8.13.1) with ESMTP id j6U4GQtc010105 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 29 Jul 2005 22:16:30 -0600 Message-ID: <42EB0700.4040600@actarg.com> Date: Fri, 29 Jul 2005 22:50:08 -0600 From: Kyle Bateman User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: bug in information_schema? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200507/248 X-Sequence-Number: 22226 I noticed that it seemed a bit slow to query information_schema.view_column_usage. As I look at the code in information_schema.sql, I'm not sure why pg_user is referenced twice (once without an alias). It looks like we can take out the first pg_user and remove the DISTINCT keyword and this improves the efficiency significantly. It seems to return the same result but in half the time. Anyone see a problem with this? (The same problem may also be in view_table_usage but I haven't done any testing there yet.) Code from information_schema.sql: CREATE VIEW view_column_usage AS SELECT DISTINCT CAST(current_database() AS sql_identifier) AS view_catalog, CAST(nv.nspname AS sql_identifier) AS view_schema, CAST(v.relname AS sql_identifier) AS view_name, CAST(current_database() AS sql_identifier) AS table_catalog, CAST(nt.nspname AS sql_identifier) AS table_schema, CAST(t.relname AS sql_identifier) AS table_name, CAST(a.attname AS sql_identifier) AS column_name FROM pg_user, pg_namespace nv, pg_class v, pg_depend dv, pg_depend dt, pg_class t, pg_namespace nt, pg_attribute a, pg_user u