Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
None
-
None
-
plugins-content-blocks, plugins-error-pages-default-hst, plugins-feedback-plugin-user-generated-content, plugins-gallery-picker, plugins-google-maps-plugin, plugins-listbuilder-hst, plugins-poll, plugins-related-docs-suggestions, plugins-rss-feed-hst, plugins-search-advanced-hst, plugins-selections, plugins-sitemap.xml, plugins-sitemenu-hst, plugins-taxonomy
-
None
Description
ALL PLUGINS NEED TO BE CHECKED FOR THIS!!
The query.execute() will authenticate ALL found results without any limits when no limit is set and ordering is used. The limit can be set by casting the Query to a HippoQuery and calling query.setLimit(). This method is also part of JCR 2.0 and as such will be available in 7.5 lifting the requirement to cast to a HippoQuery.
A good example where this is implemented wrongly is the SimilaritySearchRelatedDocsProvider:
----------------------------------------- WRONG !! ---------------------------------------------------------------------
Query query = nodeModel.getNode().getSession().getWorkspace().getQueryManager().createQuery(
statement.toString(), Query.XPATH);
RowIterator r = query.execute().getRows();
int i = 0;
while (r.hasNext() && i < 25)
----------------------------------------- WRONG !! ---------------------------------------------------------------------
The limit off 25(hardcoded!!??!!) only works for the loop iteration. The query.execute() already has fetched EVERY (thousands!) node that matches the query from the database. As this will exceed the amount of cache available this will cause an extreme amount of IO.
This should become something like:
-----------------------------------------------------------------------------------------------------------------------------------------------
HippoQuery query = (HippoQuery) nodeModel.getNode().getSession().getWorkspace().getQueryManager().createQuery(
statement.toString(), Query.XPATH);
query.setLimit(maxSimilarities);
RowIterator r = query.execute().getRows();
while (r.hasNext())
-----------------------------------------------------------------------------------------------------------------------------------------------
Please consult with Ard if you have a query and you are not sure how to fix it.
Attachments
Issue Links
- relates to
-
HIPPLUG-112 Every plugin using a query must make sure that the query contains an order by clause
- Closed
-
HIPPLUG-112 Every plugin using a query must make sure that the query contains an order by clause
- Closed