Hi,
I still have some problems with my queries. In some cases I can't avoid
joins, and combined with range "from" "to", "order by" and limit such
queries often ends up traversing whole range.
Here is example of plan costs for query without limit, searching with
recipient or sender id has much lower cost than date and query is fast.
2019-02-13 12:30:16,316 DEBUG [org.apache.jackrabbit.oak.query.QueryImpl]
(default task-1) cost for [/oak:index/docs_index] of type (lucene-property)
with plan [lucene:docs_index(/oak:index/docs_index) +dataSkladowania:[* TO
1550224980000] +dataSkladowania:[1548982860000 TO *] ordering:[{ propertyName :
dataSkladowania, propertyType : UNDEFINED, order : DESCENDING }]] is 12329,50
2019-02-13 12:30:16,315 DEBUG [org.apache.jackrabbit.oak.query.QueryImpl]
(default task-1) cost for [/oak:index/docs_index] of type (lucene-property)
with plan [lucene:docs_index(/oak:index/docs_index)
identyfikator:nadawcaid_R3_9_781] is 4893,00
When I set limit, entryCount is overriden, and as you can see in a log
fragment below traversing through range has lower costs - instead of
milliseconds query takes over 30 seconds.
maxEntryCount = offset + limit;
(...)
if (sortOrder == null || p.getSortOrder() != null) {
// if the query is unordered, or
// if the query contains "order by" and the index can sort on that,
// then we don't need to read all entries from the index
entryCount = Math.min(maxEntryCount, entryCount);
}
2019-02-13 12:50:43,016 DEBUG [org.apache.jackrabbit.oak.query.QueryImpl]
(default task-1) cost for [/oak:index/docs_index] of type (lucene-property)
with plan [lucene:docs_index(/oak:index/docs_index) +dataSkladowania:[* TO
1550224980000] +dataSkladowania:[1548982860000 TO *] ordering:[{ propertyName :
dataSkladowania, propertyType : UNDEFINED, order : DESCENDING }]] is 51,00
2019-02-13 12:51:21,265 DEBUG [org.apache.jackrabbit.oak.query.QueryImpl]
(default task-1) cost for [/oak:index/docs_index] of type (lucene-property)
with plan [lucene:docs_index(/oak:index/docs_index)
identyfikator:nadawcaid_R3_9_781] is 101,00
It looks for me that when entryCount is overriden, priorities set on
Lucene properties with weight and boost become pointless. Is there any
way to set priorities of the properties for such situations ?
Best regards,
Piotr