Skip to content

frontend: optimize SHOW ACCOUNTS account-info SQL (#24092)#24113

Merged
mergify[bot] merged 1 commit intomatrixorigin:mainfrom
LeftHandCold:show_account
Apr 10, 2026
Merged

frontend: optimize SHOW ACCOUNTS account-info SQL (#24092)#24113
mergify[bot] merged 1 commit intomatrixorigin:mainfrom
LeftHandCold:show_account

Conversation

@LeftHandCold
Copy link
Copy Markdown
Contributor

@LeftHandCold LeftHandCold commented Apr 10, 2026

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24091

What this PR does / why we need it:

Address #24091 by rewriting getSqlForAccountInfo() so SHOW ACCOUNTS computes database and table counts with separate aggregates instead of joining mo_catalog.mo_tables and mo_catalog.mo_database on account_id before COUNT(DISTINCT ...). This removes the mo_tables x mo_database amplification that dominated the getAccountInfo() CPU flamegraph, pushes exact account_id filters into the aggregate CTEs for single-account requests, and keeps the rest of the SHOW ACCOUNTS behavior unchanged. As a low-risk follow-up, this PR also hardens reconstruction of the internal LIKE predicate by escaping single quotes and backslashes, and adds combined SQL-generation plus parser round-trip coverage.

Address matrixorigin#24091 by rewriting `getSqlForAccountInfo()` so `SHOW ACCOUNTS` computes database and table counts with separate aggregates instead of joining `mo_catalog.mo_tables` and `mo_catalog.mo_database` on `account_id` before `COUNT(DISTINCT ...)`.
This removes the `mo_tables x mo_database` amplification that dominated the `getAccountInfo()` CPU flamegraph, pushes exact `account_id` filters into the aggregate CTEs for single-account requests, and keeps the rest of the `SHOW ACCOUNTS` behavior unchanged.
As a low-risk follow-up, this PR also hardens reconstruction of the internal `LIKE` predicate by escaping single quotes and backslashes, and adds combined SQL-generation plus parser round-trip coverage.

Approved by: @XuPeng-SH
@mergify mergify bot added the queued label Apr 10, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 10, 2026

Merge Queue Status

  • Entered queue2026-04-10 07:49 UTC · Rule: main
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-10 07:50 UTC · at b20d85e5d2fe648f86c610d01f4324874fdad5de

This pull request spent 11 seconds in the queue, including 1 second running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

@mergify mergify bot merged commit de47aa9 into matrixorigin:main Apr 10, 2026
43 of 45 checks passed
@mergify mergify bot removed the queued label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants