perf(cms): eliminate redundant DB queries on public CMS read path#330
Draft
jameswillis99 wants to merge 1 commit into
Draft
perf(cms): eliminate redundant DB queries on public CMS read path#330jameswillis99 wants to merge 1 commit into
jameswillis99 wants to merge 1 commit into
Conversation
Every published CMS table read was executing up to 9 DB queries per request due to duplicate table lookups and permission checks across getCmsTableByIdentifier and queryCmsRows/countCmsRows. Consolidates to 4 queries (cms_database + workspace + cms_table + cms_row) by: - Adding an accessLevel parameter to getCmsTableByIdentifier so the draft vs published permission check happens once upfront at the right level, rather than being repeated inside the row query functions. - Extracting queryCmsRowsForTable and countCmsRowsForTable which accept a pre-loaded CmsTable and skip the redundant lookup and perm check. - Updating queryTable and countTable in the public read router to use the ForTable variants after getCmsTableByIdentifier. - Removing the countCmsRows wrapper (no production callers remain) and updating the spec to call countCmsRowsForTable directly. queryCmsRows (by tableId) is preserved unchanged for cmse.ts and CmsRowCache which only have a tableId at call time. Closes #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every published CMS table read was executing up to 9 DB queries per request due to duplicate table lookups and permission checks across getCmsTableByIdentifier and queryCmsRows/countCmsRows.
Consolidates to 4 queries (cms_database + workspace + cms_table + cms_row) by:
queryCmsRows (by tableId) is preserved unchanged for cmse.ts and CmsRowCache which only have a tableId at call time.