information_schema query not working in PostgreSQL version 17

Jorge Campins <jrcampins@gmail.com>

From: Jorge Campins <jrcampins@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2025-05-14T21:57:45Z
Lists: pgsql-bugs

Attachments

Dears Sirs,

You will find attached 2 sql files:

   - select-for-version-16-or-lower.sql
   - select-for-version-17

Both queries return the same result; I've been using the
select-for-version-16-or-under query since a few versions ago. Since
upgrading to version 17, it doesn't work with a database with many defined
constraints. By many, I mean:

   - 9104 rows in table_constraints
   - 2592 rows in referential_constraints
   - 4476 rows in key_column_usage

The original query never completes in version 17; I tried several times and
always canceled it after 30 minutes. To make it work in version 17, I had
to add redundant search criteria. You can understand what I mean by
comparing the attached files. The original query runs in approximately 45
seconds on version 16; the version 17 query runs in approximately 68
seconds, using the same data.

I have never reported an iissue for PostgreSQL before. Ihope this is the
proper way to do it.

Regardse,

Jorge Campins