Skip to content

perf: Enhance objects using constant sql queries count to get rid of N+1 queries - #2857

Open
Koc wants to merge 3 commits into
mainfrom
feature/optimize-enhance-tables
Open

perf: Enhance objects using constant sql queries count to get rid of N+1 queries#2857
Koc wants to merge 3 commits into
mainfrom
feature/optimize-enhance-tables

Conversation

@Koc

@Koc Koc commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

In our organization we operate a large amount of tables/views, so there are performance bottleneck here:

PERFORMANCE: Controller OCA\\Tables\\Controller\\Api1Controller::index executed 1883 queries in 20.1 seconds
PERFORMANCE: Controller OCA\\Tables\\Controller\\TableController::index executed 1887 queries in 16.6 seconds
  • Replaced TableService::enhanceTable() in a loop with a single call of the enhanceTables()
  • Replaced ViewService::enhanceView() in a loop with a single call of theenhanceViews()
  • Added batch helpers in mappers/services and UserHelper for row/column counts, share counts and owner display names.

🖼️ Screenshots

Here profiler results for GET /apps/tables/table endpoint for 18 tables and 9 views:

🏚️ Before 🏡 After
121 queries 29 queries
image image

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@Koc
Koc force-pushed the feature/optimize-enhance-tables branch 2 times, most recently from 9b6bd68 to 4033598 Compare July 29, 2026 00:28
…f N+1 queries

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc
Koc marked this pull request as ready for review July 29, 2026 18:08
@Koc
Koc requested review from blizzz and enjeck as code owners July 29, 2026 18:08
@Koc Koc changed the title perf: Call enhanceTables for a multiple tables at once to get rid of N+1 queries perf: Enhance objects for a multiple tables at once to get rid of N+1 queries Jul 29, 2026
@Koc Koc changed the title perf: Enhance objects for a multiple tables at once to get rid of N+1 queries perf: Enhance objects using constant sql queries count to get rid of N+1 queries Jul 29, 2026
…1 queries

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc
Koc force-pushed the feature/optimize-enhance-tables branch from 4033598 to 29cbb47 Compare July 29, 2026 21:50
…rid of N+1 queries

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc
Koc force-pushed the feature/optimize-enhance-tables branch from 29cbb47 to 44e315b Compare July 29, 2026 21:57
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.

1 participant