Added smarterCounts labs flag for optimized pagination count queries#26709
Added smarterCounts labs flag for optimized pagination count queries#26709kevinansfield merged 1 commit intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughAdds a private lab feature 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
@kevinansfield I've merged the framework PR and bumped the packages so they can be included here. |
e53fc54 to
69b38a8
Compare
🤖 Velo CI Failure AnalysisClassification: 🟠 SOFT FAIL
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26709 +/- ##
==========================================
- Coverage 73.19% 73.18% -0.01%
==========================================
Files 1534 1534
Lines 121048 121054 +6
Branches 14636 14634 -2
==========================================
- Hits 88601 88597 -4
- Misses 31415 31425 +10
Partials 1032 1032
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🤖 Velo CI Failure AnalysisClassification: 🟠 SOFT FAIL
|
924df3c to
80f3323
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ghost/core/core/server/models/base/plugins/crud.js`:
- Around line 147-150: Move the inline require of labs out of the findPage
function into module scope: add a top-level const labs =
require('../../../../shared/labs'); and remove the inline require inside
findPage; then keep the existing conditional that sets options.useSmartCount =
true when labs.isSet('smarterCounts') is true. Update any references in the file
to use the module-scoped labs variable (e.g., inside findPage) to avoid repeated
requires and match the pattern used in settings.js.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f98f02f5-9155-49a9-903b-4bcf82bde6b4
⛔ Files ignored due to path filters (3)
ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snapis excluded by!**/*.snapghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snapis excluded by!**/*.snapyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
apps/admin-x-settings/src/components/settings/advanced/labs/private-features.tsxghost/core/core/server/models/base/plugins/crud.jsghost/core/core/shared/labs.jsghost/core/package.jsonghost/core/test/e2e-api/content/posts.test.js
d871177 to
d1be93a
Compare
refs https://linear.app/ghost/issue/ENG-000 - Added `smarterCounts` private labs flag - Updated `@tryghost/bookshelf-plugins` to 2.0.2 (includes bookshelf-pagination with useSmartCount support for count(*) on single-table queries) - When enabled, uses count(*) instead of count(distinct id) for simple queries
d1be93a to
b860e8e
Compare
Summary
smarterCountsprivate labs flag that automatically optimizes pagination count queriesCOUNT(*)when safe (no JOINs), falling back toCOUNT(DISTINCT table.id)when JOINs are presentproducts(LEFT JOIN onstripe_prices) — all other models benefit from the fasterCOUNT(*)COUNT(DISTINCT)toCOUNT(*)Tables that benefit (based on queries made during e2e-api tests)
Changes
ghost/core/core/shared/labs.js— AddedsmarterCountsto private featuresghost/core/core/server/models/base/plugins/crud.js— SetsuseSmartCountoption when labs flag is enabledapps/admin-x-settings/.../private-features.tsx— Added labs UI toggleghost/core/test/e2e-api/content/posts.test.js— Fixed overly broadselect *assertion that was catchingcount(*)Companion PR
Framework: TryGhost/framework#434 (adds
useSmartCountoption to@tryghost/bookshelf-pagination)