Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3a58c8

Browse files
committed
Optimize query for information_schema.constraint_column_usage
The way the old query was written prevented some join optimizationsbecause the join conditions were hidden inside a CASE expression. Witha large number of constraints, the query became unreasonably slow. Thenew query performs much better.From: Alexey Bashtanov <bashtanov@imap.cc>Reviewed-by: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
1 parent68f3dbc commite3a58c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/backend/catalog/information_schema.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,8 @@ CREATE VIEW constraint_column_usage AS
801801
WHEREnr.oid=r.relnamespace
802802
ANDr.oid=a.attrelid
803803
ANDnc.oid=c.connamespace
804-
AND(CASE WHENc.contype='f' THENr.oid=c.confrelidANDa.attnum= ANY (c.confkey)
805-
ELSEr.oid=c.conrelidANDa.attnum= ANY (c.conkey) END)
804+
ANDr.oid= CASEc.contypeWHEN'f' THENc.confrelidELSEc.conrelid END
805+
ANDa.attnum= ANY (CASEc.contype WHEN'f' THENc.confkey ELSEc.conkey END)
806806
AND NOTa.attisdropped
807807
ANDc.contypeIN ('p','u','f')
808808
ANDr.relkindIN ('r','P')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp