Commit b59c594
authored
Materialize table_types_internal as CTE in sys.all_objects to prevent view inlining (#4682)
The sys.all_objects view joins against sys.table_types_internal to exclude table types from the user table
branches. Because table_types_internal is a plain view, the planner inlines its definition (a 4-way join across
pg_type, pg_namespace, pg_class, pg_depend) and re-executes it per row inside a nested loop, causing
significant performance degradation.
This change wraps table_types_internal in a materialized CTE inside sys.all_objects so it is computed once and
reused.
Task: BABEL-6404
Signed-off-by: Rucha Kulkarni <ruchask@amazon.com>1 parent c50c662 commit b59c594
File tree
8 files changed
+442
-3
lines changed- contrib/babelfishpg_tsql/sql
- upgrades
- test/JDBC
- expected
- input/views
8 files changed
+442
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1293 | 1293 | | |
1294 | 1294 | | |
1295 | 1295 | | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1296 | 1299 | | |
1297 | 1300 | | |
1298 | 1301 | | |
| |||
1327 | 1330 | | |
1328 | 1331 | | |
1329 | 1332 | | |
1330 | | - | |
| 1333 | + | |
1331 | 1334 | | |
1332 | 1335 | | |
1333 | 1336 | | |
| |||
1352 | 1355 | | |
1353 | 1356 | | |
1354 | 1357 | | |
1355 | | - | |
| 1358 | + | |
1356 | 1359 | | |
1357 | 1360 | | |
1358 | 1361 | | |
| |||
0 commit comments