Repository navigation
perf(postgres): batch DROP statements in clearDatabase() - #12164
Conversation
Consolidate individual DROP VIEW/TABLE/TYPE queries into single batched statements, reducing N+1 round trips to 1 per object type.
Review Summary by QodoBatch DROP statements in PostgreSQL clearDatabase()
WalkthroughsDescription• Batch DROP statements for views, materialized views, tables, and enum types • Reduces N+1 database round trips to single query per object type • Switches enum name quoting to quote_ident() for special character handling • Improves clearDatabase() performance by consolidating individual DROP queries Diagramflowchart LR
A["Individual DROP queries<br/>N+1 round trips"] -->|Consolidate| B["Batched DROP statements<br/>1 round trip per type"]
C["Raw string concatenation<br/>for enum names"] -->|Switch to| D["quote_ident() function<br/>handles special chars"]
B --> E["Improved performance"]
D --> E
File Changes1. src/driver/postgres/PostgresQueryRunner.ts
|
commit: |
Code Review by Qodo
1. Unescaped schema IN list
|
Deploying typeorm with
|
| Latest commit: |
9bc9176
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8c9e5497.typeorm.pages.dev |
| Branch Preview URL: | https://perf-batch-postgres-drop-sta.typeorm.pages.dev |
|
Persistent review updated to latest commit 9bc9176 |
|
|
Persistent review updated to latest commit 4292735 |



Consolidate individual DROP VIEW/TABLE/TYPE queries into single batched statements, reducing N+1 round trips to 1 per object type. Same optimization as #12159 for CockroachDB.
DROP VIEW IF EXISTS a, b, c CASCADEDROP MATERIALIZED VIEW IF EXISTS a, b, c CASCADEDROP TABLE IF EXISTS a, b, c CASCADEDROP TYPE IF EXISTS a, b, c CASCADEAlso switches enum name quoting from raw string concatenation to
quote_ident()for correctness with special characters.