machov opened a new pull request, #3939:
URL: https://github.com/apache/polaris/pull/3939
## Problem
Issue #3685 reports critical performance degradation where
`create_namespace` API operations consistently timeout (>30s), causing
cascading failures with 504 Gateway Timeouts.
## Root Cause Analysis
Database analysis revealed:
- **65,000+ permission check queries** performing full table scans on
`grant_records`
- **Bulk entity lookups** with ~7,800 tuples causing inefficient query plans
- **13.7 billion rows read** during a single create_namespace operation
## Solution
Added schema v5 with three performance-critical indexes:
1. **`idx_grants_realm_grantee`** on `grant_records(realm_id, grantee_id)`
- Eliminates sequential scans for permission checks
2. **`idx_grants_realm_securable`** on `grant_records(realm_id,
securable_id)`
- Optimizes grant record cleanup and GC operations
3. **`idx_entities_catalog_id_id`** on `entities(catalog_id, id)`
- Optimizes bulk entity lookups with large IN clauses
## Performance Impact
Based on issue reporter's testing:
- **Before**: create_namespace consistently 33-36 seconds
- **After**: Latency dropped to **under 2 seconds**
## Database Compatibility
- ✅ PostgreSQL schema v5 created
- ✅ H2 schema v5 created
- ✅ Uses `IF NOT EXISTS` for safe deployment
Fixes #3685
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]