Significant Execution Time Difference Between PG13.14 and PG16.4 for Query on information_schema Tables.
nikhil raj <nikhilraj474@gmail.com>
From: nikhil raj <nikhilraj474@gmail.com>
To: "pgsql-generallists.postgresql.org" <pgsql-general@lists.postgresql.org>
Cc: NIKITA PATEL <patelnikita1411@gmail.com>,
Patel Khushbu <patelkhushbu2067@gmail.com>
Date: 2024-08-26T21:49:04Z
Lists: pgsql-hackers, pgsql-general
Attachments
- PG13_32644.txt (text/plain)
- PG16_32644.txt (text/plain)
Hi All,
I've encountered a noticeable difference in execution time and query
execution plan row counts between PostgreSQL 13 and PostgreSQL 16 when
running a query on information_schema tables. Surprisingly, PostgreSQL 16
is performing slower than PostgreSQL 13.
The query executed on both versions is as follows:
SELECT DISTINCT "tc"."constraint_name" AS "ConstraintName",
"ccu"."column_name" AS "ColumnName"
FROM
information_schema.constraint_column_usage AS "ccu" right join
information_schema.table_constraints AS "tc"
ON "tc"."constraint_catalog" = "ccu"."constraint_catalog"
AND "tc"."constraint_name" = "ccu"."constraint_name"
WHERE "tc"."constraint_type" = 'PRIMARY KEY'
AND "ccu"."table_name" = 't_c56ng1_repository'
Here are the details of the PostgreSQL versions and the execution plans:
*4PostgreSQL 13.14 (PostgreSQL 13.14 on x86_64-pc-linux-gnu, compiled by
gcc 11.4.0, 64-bit)*
Execution plan: PG13.14 Execution Plan
<https://explain.dalibo.com/plan/ag1a62a9d47dg29d>
*PostgreSQL 16.4 (PostgreSQL 16.4 on x86_64-pc-linux-gnu, compiled by gcc
11.4.0, 64-bit)*
Execution plan: PG16.4 Execution Plan
<https://explain.dalibo.com/plan/4c66fdfbf2hf9ed2>
Has anyone else experienced similar behavior or could provide insights into
why PostgreSQL 16 might be slower for this query? Any advice or suggestions
for optimization would be greatly appreciated.
Thank you!
NOTE:- PFA the raw file of explain and analyze below.
Commits
-
Avoid inserting PlaceHolderVars in cases where pre-v16 PG did not.
- b43110869fd8 17.0 landed
- 80d9c07a4a8c 16.5 landed
- cb8e50a4a09f 18.0 landed
-
Remove one memoize test case added by commit 069d0ff02.
- 3409b4db631f 18.0 landed