bug in information_schema?

From: Kyle Bateman <kyle(at)actarg(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: bug in information_schema?
Date: 2005-07-30 04:50:08
Message-ID: 42EB0700.4040600@actarg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-07-30 13:15:05 Re: How to loop though an array plpgsql?
Previous Message Matthew Schumacher 2005-07-29 23:39:12 How to loop though an array plpgsql?