You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(query): optimize visibility checker for large-scale deployments improved 10x (#18954)
* refactor(query): optimize grant object visibility checker for large-scale deployments
This commit improves the performance of grant object visibility checking,
which is critical for SHOW TABLES/DATABASES operations and privilege
verification in large deployments with hundreds of thousands of objects.
Key optimizations:
- Skip ownership loading for account_admin role (has unrestricted access)
- Replace HashMap/HashSet with FastHashMap/FastHashSet for integer keys
- Introduce CatalogIdPool to map catalog names to u32 IDs, avoiding
repeated string hashing in hot paths
- Pre-allocate hash table capacity based on ownership count
- Optimize database/table ownership lookups using composite integer keys
Benchmark results show significant improvements for large-scale scenarios:
- 100K objects: construction time reduced from O(n log n) to O(n)
- 1M tables: SHOW TABLES performance improved by ~6x
- 100K tables: SHOW TABLES performance improved by ~10x
- Multi-catalog scenarios: reduced memory overhead and faster lookups
* fix
* extract method
* use BUILTIN_ROLE_ACCOUNT_ADMIN replace account_admin
0 commit comments