Skip to content

Conversation

@sureshanaparti
Copy link
Contributor

Description

This PR allows the limit queries without random ordering.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@sureshanaparti sureshanaparti changed the base branch from main to 4.20 February 5, 2026 14:04
@sureshanaparti sureshanaparti changed the title Db filter with limit Allow limit queries without random ordering Feb 5, 2026
@sureshanaparti sureshanaparti added this to the 4.20.3 milestone Feb 5, 2026
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@DaanHoogland
Copy link
Contributor

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.27%. Comparing base (3d7d412) to head (b57892b).

Files with missing lines Patch % Lines
...rk/db/src/main/java/com/cloud/utils/db/Filter.java 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12598   +/-   ##
=========================================
  Coverage     16.26%   16.27%           
- Complexity    13429    13432    +3     
=========================================
  Files          5661     5661           
  Lines        500010   500014    +4     
  Branches      60715    60716    +1     
=========================================
+ Hits          81331    81361   +30     
+ Misses       409606   409579   -27     
- Partials       9073     9074    +1     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.12% <71.42%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sureshanaparti
Copy link
Contributor Author

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

random sorting may not be required in all cases. It requires the use of a temporary table for the sort, which is taking more time for a simple lookup by name of a VM.

Comment on lines +69 to +74
if (randomize) {
_orderBy = " ORDER BY RAND()" ;
_limit = limit;
} else {
_limit = limit;
}
Copy link
Member

@winterhazel winterhazel Feb 5, 2026

Choose a reason for hiding this comment

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

Suggested change
if (randomize) {
_orderBy = " ORDER BY RAND()" ;
_limit = limit;
} else {
_limit = limit;
}
_limit = limit;
if (randomize) {
_orderBy = " ORDER BY RAND()" ;
}

@winterhazel
Copy link
Member

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

@DaanHoogland there are some usages for it. I used an alternative approach in 02d8f18 for batch expunge. That one line in GenericDaoBase may be changed to filter = new Filter(batchSizeFinal, false);

@winterhazel
Copy link
Member

winterhazel commented Feb 5, 2026

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@DaanHoogland
Copy link
Contributor

ok, guys, I see how it could have been useful for instance in @winterhazel ’s change. In this PR however it is not used at all. Are we planning to …?

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants