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

ISPN-14194 Add config property for default max result #10378

Merged
merged 11 commits into from Oct 17, 2022

Conversation

fax4ever
Copy link
Contributor

@fax4ever fax4ever commented Oct 10, 2022

https://issues.redhat.com/browse/ISPN-14194

Just the first step, that is adding the config property for it. ready for the review
I'm writing the documentation

@tristantarrant tristantarrant added this to the 14.0.1.Final milestone Oct 11, 2022
<xs:attribute name="default-max-result" type="xs:integer" default="${Query.default-max-result}">
<xs:annotation>
<xs:documentation>
Applies the given value as maxResults as a default to any query (indexed, non-indexed and hybrid).
Copy link
Member

Choose a reason for hiding this comment

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

A suggestion:
Limits the number of results returned by a query. Applies to indexed, non-indexed, and hybrid queries. Setting the default-max-results significantly improves performance of queries that don't have an explicit limit set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me

@tristantarrant
Copy link
Member

The name of the property should be plural (default-max-results)

@fax4ever
Copy link
Contributor Author

Thank you for the review @dvagnero and @tristantarrant, going to apply the changes.
In the meantime I have completed the implementation, but we still need to address the documentation.

@fax4ever fax4ever force-pushed the ISPN-14194 branch 2 times, most recently from 66110c0 to d702cd0 Compare October 14, 2022 07:40
@fax4ever fax4ever marked this pull request as ready for review October 14, 2022 08:57
@fax4ever
Copy link
Contributor Author

I applied the changes and fixed the last stuff. I'm writing my doc additions.

@@ -104,6 +111,10 @@ public SearchQueryBuilder getSearchQueryBuilder() {
return searchQueryBuilder;
}

public boolean maxResultsHasChanged() {
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the name. Maybe isCustomMaxResults() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. changed it

*/
public class QueryConfiguration extends AbstractTypedPropertiesConfiguration implements Matchable<QueryConfiguration> {

public static final AttributeDefinition<Integer> DEFAULT_MAX_RESULTS = AttributeDefinition.builder(org.infinispan.configuration.parsing.Attribute.DEFAULT_MAX_RESULTS, 100).immutable().build();
Copy link
Member

Choose a reason for hiding this comment

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

For now, immutable is fine, but in the future we could turn this into a runtime-mutable attribute. Can you create a Jira for it ?

Copy link
Member

@tristantarrant tristantarrant left a comment

Choose a reason for hiding this comment

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

One small change in a method name. Otherwise LGTM

@tristantarrant
Copy link
Member

We may want to add some query benchmarks to https://github.com/infinispan/infinispan-benchmarks

@fax4ever
Copy link
Contributor Author

thanks @tristantarrant for the review!
I made the changes and created the follow up: https://issues.redhat.com/browse/ISPN-14232

@fax4ever
Copy link
Contributor Author

@dvagnero I made my attempt to document the (restored) behavior and the new property here: ISPN-14194 Document query default max results

@fax4ever
Copy link
Contributor Author

fax4ever commented Oct 14, 2022

@wfink I don't know if you want to take a look at it

Comment on lines 126 to 131
== Query efficiency

Restore the default query max results that used to be present in older Infinispan versions (prior of 12.1.5.Final)
and provide a new configuration attribute to change this default, that is now restored to 100.
Limiting the number of results returned by a query. Applies to indexed, non-indexed, and hybrid queries.
It significantly improves performance of queries that don't have an explicit limit set.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
== Query efficiency
Restore the default query max results that used to be present in older Infinispan versions (prior of 12.1.5.Final)
and provide a new configuration attribute to change this default, that is now restored to 100.
Limiting the number of results returned by a query. Applies to indexed, non-indexed, and hybrid queries.
It significantly improves performance of queries that don't have an explicit limit set.
== Query efficiency
The `default-max-results` property that was present in Infinispan 12.1.5.Final and earlier versions has been restored.
This property limits the number of results returned by a query and significantly improves performance of queries that don't have an explicit limit set.
The default value of `default-max-results` is 100.

Copy link
Member

Choose a reason for hiding this comment

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

Not quite @dvagnero : Infinispan never had a default-max-results property. It just had a default, unmodifiable value for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dvagnero, I merged them:

The default query max results that was present in Infinispan 12.1.5.Final and earlier versions has been restored,
together with the fact that you can now also change this default by setting the query.default-max-results cache property.
Limiting the number of results returned by a query significantly improves performance of queries that don't have an explicit limit set.
The default value of default-max-results is 100.

@dvagnero what do you think of?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! What about...
The default for maximum results returned by a query that was present in Infinispan 12.1.5.Final and earlier versions has been restored. You can now change the default limit by setting the default-max-results cache property. The default value of default-max-results is 100.
Limiting the number of results returned by a query significantly improves performance of queries that don't have an explicit limit set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds great to me... I'm applying it. Thanks

Comment on lines 43 to 44
The default limit of `100` is applied if `maxResults` is not explicitly set to the query instance.
You can change this default for all the queries by setting the cache property `query.default-max-result`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The default limit of `100` is applied if `maxResults` is not explicitly set to the query instance.
You can change this default for all the queries by setting the cache property `query.default-max-result`.
NOTE
====
If you don't explicitly set the `MaxResults` for a query instance, {brandname} limits the number of results returned by the query to `100`.
You can change the default limit by setting the `query.default-max-results` cache property.
====

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied, thanks!

@fax4ever
Copy link
Contributor Author

fax4ever commented Oct 17, 2022

I applied the changes to the docs, thanks @dvagnero!

That is the way aggregations currently work, the inefficiency could be removed delegating them to Search! (see ISPN-13986)
-1 is not the infinite any more, it means apply the default, and the default is not the infinite anymore
Hybrid query, as they are, they require an unbounded max results, another reason to avoid using them
@fax4ever
Copy link
Contributor Author

Applied the last changes from @dvagnero.
I think that we can merge it if the CI passes.

@tristantarrant
Copy link
Member

tristantarrant commented Oct 17, 2022

In the previous run there were two thread leaks associated with indexing tests:

ThreadLeakChecker – org.infinispan.query.api.ManualIndexingTest
ThreadLeakChecker – org.infinispan.query.distributed.MassIndexingTest

@fax4ever
Copy link
Contributor Author

In the previous run there were two thread leaks associated with indexing tests:

ThreadLeakChecker – org.infinispan.query.api.ManualIndexingTest ThreadLeakChecker – org.infinispan.query.distributed.MassIndexingTest

@tristantarrant I don't know how the current changes may affect those tests. I think that we could have the same failures on the main branch.

@tristantarrant tristantarrant merged commit bf9dd71 into infinispan:main Oct 17, 2022
@tristantarrant
Copy link
Member

Merged, thanks

@fax4ever
Copy link
Contributor Author

Thank you!

@fax4ever fax4ever deleted the ISPN-14194 branch October 17, 2022 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants