Description
Currently if multiple indexes compete for same query i.e. they report cost > 0 and less than infinity then the log output is confusing. For e.g. for a query like
QueryEngineImpl Parsing xpath statement: /jcr:root/content/dam//element(*, dam:Asset)[jcr:contains(., 'foo.png')] QueryEngineImpl XPath > SQL2: select [jcr:path], [jcr:score], * from [dam:Asset] as a where contains(*, 'foo.png') and isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, dam:Asset)[jcr:contains(., 'foo.png')] */ QueryImpl cost using filter Filter(query=select [jcr:path], [jcr:score], * from [dam:Asset] as a where contains(*, 'foo.png') and isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, dam:Asset)[jcr:contains(., 'foo.png')] */ fullText="foo.png", path=/content/dam//*) QueryImpl cost for aggregate lucene is 2.2424751E7 QueryImpl cost for lucene-property[/oak:index/index-a][/oak:index/index-b] is 146914.0 QueryImpl cost for reference is Infinity QueryImpl cost for ordered is Infinity QueryImpl cost for nodeType is Infinity QueryImpl cost for property is Infinity QueryImpl cost for traverse is Infinity QueryImpl query execute select [jcr:path], [jcr:score], * from [dam:Asset] as a where contains(*, 'foo.png') and isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, dam:Asset)[jcr:contains(., 'foo.png')] */ QueryImpl query plan [dam:Asset] as [a] /* lucene:index-b(/oak:index/index-b) +(((...) +:ancestors:/content/dam ft:("foo.png") where (contains([a].[*], 'foo.png')) and (isdescendantnode([a], [/content/dam])) */ QueryImpl query execute select [jcr:path], [jcr:score], * from [dam:Asset] as a where contains(*, 'foo.png') and isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, dam:Asset)[jcr:contains(., 'foo.png')] */ QueryImpl query plan [dam:Asset] as [a] /* lucene:index-b(/oak:index/index-b) +(((...)) +:ancestors:/content/dam ft:("foo.png") where (contains([a].[*], 'foo.png')) and (isdescendantnode([a], [/content/dam])) */
Here both index-a and index-b satisfy the query. However from logs it appears that both have same cost. While actually the reported cost is the lowest one which in this case would be for index-b
QueryImpl cost for lucene-property[/oak:index/index-a][/oak:index/index-b] is 146914.0
So as a fix
- Report cost for multiple plans returned by same index type separately
- If cost is less than infinity and that plan is eventually not selected then also log its plan. This would help to see why specific plan lost
Attachments
Issue Links
- relates to
-
OAK-4652 indexName logged in QueryImpl is wrong in case of multiple indexes satisfying the query
- Closed