Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3f7626e

Browse files
committed
A couple of marginal performance hacks for the information_schema views:
replace the old recursive-SQL-function implementation of _pg_keysequal() with use of the built-in array containment operators, and change table_constraints' UNION to UNION ALL. Per discussion with Octavio Alvarez. initdb not forced since this doesn't affect results, but you'd need to initdb or reload the information_schema to see the new definitions.
1 parent ca5646f commit 3f7626e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/backend/catalog/information_schema.sql

+4-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.51 2009/02/06 21:15:11 tgl Exp $
7+
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.52 2009/02/14 20:48:36 tgl Exp $
88
*/
99

1010
/*
@@ -40,17 +40,9 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
4040
pg_catalog.array_upper($1,1),
4141
1) as g(s)';
4242

43-
CREATE FUNCTION _pg_keyissubset(smallint[], smallint[]) RETURNS boolean
44-
LANGUAGE sql
45-
IMMUTABLE
46-
RETURNS NULL ON NULL INPUT
47-
AS 'select $1[1] is null or ($1[1] = any ($2) and coalesce(information_schema._pg_keyissubset($1[2:pg_catalog.array_upper($1,1)], $2), true))';
48-
4943
CREATE FUNCTION _pg_keysequal(smallint[], smallint[]) RETURNS boolean
50-
LANGUAGE sql
51-
IMMUTABLE
52-
RETURNS NULL ON NULL INPUT
53-
AS 'select information_schema._pg_keyissubset($1, $2) and information_schema._pg_keyissubset($2, $1)';
44+
LANGUAGE sql IMMUTABLE -- intentionally not STRICT, to allow inlining
45+
AS 'select $1 <@ $2 and $2 <@ $1';
5446

5547
/* Get the OID of the unique index that an FK constraint depends on */
5648
CREATE FUNCTION _pg_underlying_index(oid) RETURNS oid
@@ -1793,7 +1785,7 @@ CREATE VIEW table_constraints AS
17931785
OR has_table_privilege(r.oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
17941786
OR has_any_column_privilege(r.oid, 'INSERT, UPDATE, REFERENCES') )
17951787

1796-
UNION
1788+
UNION ALL
17971789

17981790
-- not-null constraints
17991791

0 commit comments

Comments
 (0)