sql/catalog: rework validation and hydration to use cached descriptors #72402
Labels
A-schema-descriptors
Relating to SQL table/db descriptor handling.
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Is your feature request related to a problem? Please describe.
Today validation, including cross descriptor validation, occurs when reading a descriptor from the store in the
catalogkv
package. This is a low-level layer. The cross-descriptor validation not only validates the references from the descriptor being retrieved to what it references, it also fetches the dependencies one layer deeper so that that all references of descriptors which should back-reference this descriptor are validated.This can cause real efficiency problems when, say, resolving schemas. Each schema will resolve its database which will, in turn, resolve all of the schemas. This is an O(N^2) proposition.
Describe the solution you'd like
To me, a key problem is the layering between retrieval of "raw" descriptors from the database and its relationship to validation. Instead of fetching and validating in one call, we should fetch and return a builder and then validate using already fetched descriptors in the descriptor collection. This can avoid the need to fetch any additional descriptors from the store most of the time.
Describe alternatives you've considered
We could do less cross-descriptor validation.
Additional context
Relates to #64388 and #64089.
Epic: CRDB-11534
Jira issue: CRDB-11135
The text was updated successfully, but these errors were encountered: