Skip to content

datastore: UNION ALL for mysql list entries query - #7113

Merged
sorindumitru merged 1 commit into
spiffe:mainfrom
zmt:mysqlUnionAllFix
Jul 2, 2026
Merged

sorindumitru merged 1 commit into
spiffe:mainfrom
zmt:mysqlUnionAllFix

Conversation

@zmt

@zmt zmt commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality
Improve performance for list registration queries in mysql 8+.

Description of change
We have seen high CPU on mysql DB. Optimizing this frequent query should help. This brings the mysql 8 and above that supports WITH clause on par with postgresql. Essentially port
#4111 to
buildFetchRegistrationEntriesQueryMySQLCTE.

We have seen high CPU on mysql DB. Optimizing this frequent query should
help. This brings the mysql 8 and above that supports WITH clause on par
with postgresql. Essentially port
spiffe#4111 to
buildFetchRegistrationEntriesQueryMySQLCTE.

Signed-off-by: ztrain <[email protected]>
Copilot AI review requested due to automatic review settings July 2, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the MySQL 8+ CTE-based registration entry fetch query in the SQL datastore to avoid the UNION de-duplication step, aligning with the performance rationale previously applied to PostgreSQL.

Changes:

  • Replace UNION with UNION ALL in buildFetchRegistrationEntriesQueryMySQLCTE to avoid unnecessary DISTINCT work.
  • Preserve query shape and ordering to keep result parsing behavior unchanged.

@sorindumitru sorindumitru left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @zmt !

@sorindumitru sorindumitru added this to the 1.15.2 milestone Jul 2, 2026
@sorindumitru
sorindumitru added this pull request to the merge queue Jul 2, 2026
Merged via the queue into spiffe:main with commit 9274936 Jul 2, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants