Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small enhancement for in memory evaluation of polymorphic query #3654

Open
csharper2010 opened this issue Feb 26, 2025 · 0 comments
Open

Small enhancement for in memory evaluation of polymorphic query #3654

csharper2010 opened this issue Feb 26, 2025 · 0 comments

Comments

@csharper2010
Copy link
Contributor

Currently, we get the warning...

firstResult/maxResults specified on polymorphic query; applying in memory!

... quite often with queries having set a MaxRows row selection on a base entity class of polymorphic nature.

There are situations where it is absolutely correct to warn in such a case:

  • some results should be skipped with set FirstResult: the skipped records need to be calculated in memory
  • the query has an order by clause: the ordering is not handled correctly

In my case, I have the situation where I want to check if there are entities for a certain criteria or I just want to find some of them as a worklist for now. I don't care about sort order (there is no order by clause in the query).

In this case I would expect

  • to get the query translators are evaluated step by step until I reach the MaxRows limit
  • to not get a warning

In each iteration over the translators, we can calculate the maximum number of to-be-fetched rows as the difference between the total MaxRows and the already fetched rows. Additionally, I would like to change the includedCount variable to be zero-based and not minus-one-based because that's counterintuitive.

csharper2010 added a commit to csharper2010/nhibernate-core that referenced this issue Feb 26, 2025
HQLQueryPlan for polymorphic query:
* Calculate a row selection in with the remaining number of rows as MaxRows
* Warn only in cases where correctness or performance may suffer
* Make includedCount zero-based
csharper2010 added a commit to csharper2010/nhibernate-core that referenced this issue Feb 26, 2025
HQLQueryPlan for polymorphic query:
* Calculate a row selection in with the remaining number of rows as MaxRows
* Warn only in cases where correctness or performance may suffer
* Make includedCount zero-based
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

No branches or pull requests

1 participant