-
Bug
-
Resolution: Done
-
Major
-
4.3.0.Final
-
None
I'm running into an issue with the following example node types, indexes and query:
mix:custom > mix:title - nt:a (string) mix:custom2 > mix:title - nt:b (string) <index name="custom_names" provider-name="local" synchronous="true" node-type="mix:custom" columns="jcr:name(NAME)" /> <index name="custom2_names" provider-name="local" synchronous="true" node-type="mix:custom2" columns="jcr:name(NAME)" /> SELECT * FROM [mix:custom] as custom where custom.[jcr:name] = 'myFirstBook'
This fails to find any nodes even though one exists. If I remove the 'custom2_names' index the query works.
The plan for the failed query is
JCR-SQL2 -> SELECT * FROM [mix:custom] as custom where custom.[jcr:name] = 'myFirstBook' AQM -> SELECT * FROM [mix:custom] AS custom WHERE custom.[jcr:name] = 'myFirstBook' plan -> Access [custom] Project [custom] <PROJECT_COLUMNS=[custom.[jcr:title], custom.[jcr:description], custom.[mode:localName], custom.[mode:id], custom.[mode:depth], custom.[jcr:score], custom.[jcr:path], custom.[jcr:name]], PROJECT_COLUMN_TYPES=[STRING, STRING, STRING, STRING, LONG, DOUBLE, STRING, STRING]> Select [custom] <SELECT_CRITERIA=NAME(custom) = 'myFirstBook'> Select [custom] <SELECT_CRITERIA=custom.[jcr:mixinTypes] = 'mix:custom'> Source [custom] <SOURCE_NAME=__ALLNODES__, SOURCE_ALIAS=custom, SOURCE_COLUMNS=[jcr:isCheckedOut(BOOLEAN), jcr:defaultPrimaryType(STRING), mode:uri(STRING), mode:lockingSession(STRING), jcr:etag(STRING), jcr:created(DATE), jcr:sameNameSiblings(BOOLEAN), jcr:encoding(STRING), jcr:workspace(STRING), jcr:activityTitle(STRING), jcr:mergeFailed(STRING), jcr:frozenMixinTypes(STRING), jcr:isQueryOrderable(BOOLEAN), jcr:lastModifiedBy(STRING), jcr:childVersionHistory(STRING), mode:synchronous(BOOLEAN), jcr:repository(STRING), mode:derivedAt(DATE), jcr:lastModified(DATE), jcr:successors(STRING), jcr:availableQueryOperators(STRING), mode:derivedFrom(STRING), jcr:primaryItemName(STRING), mode:isSessionScoped(BOOLEAN), jcr:frozenUuid(STRING), jcr:isFullTextSearchable(BOOLEAN), jcr:defaultValues(STRING), mode:sharedUuid(STRING), jcr:predecessors(STRING), jcr:content(STRING), mode:projectedNodeKey(STRING), jcr:language(STRING), jcr:valueConstraints(STRING), mode:sha1(STRING), jcr:activity(STRING), jcr:requiredPrimaryTypes(STRING), jcr:baseVersion(STRING), jcr:requiredType(STRING), jcr:autoCreated(BOOLEAN), jcr:isAbstract(BOOLEAN), mode:externalNodeKey(STRING), jcr:hasOrderableChildNodes(BOOLEAN), mode:lockToken(STRING), mode:kind(STRING), mode:alias(STRING), mode:columnTypeName(STRING), jcr:text(STRING), jcr:mimeType(STRING), mode:workspace(STRING), jcr:data(BINARY), jcr:port(STRING), jcr:protected(BOOLEAN), jcr:primaryType(STRING), mode:expirationDate(DATE), jcr:id(STRING), privileges(STRING), jcr:host(STRING), jcr:lifecyclePolicy(STRING), jcr:versionHistory(STRING), jcr:mixinTypes(STRING), jcr:isQueryable(BOOLEAN), jcr:mandatory(BOOLEAN), jcr:lockIsDeep(BOOLEAN), jcr:currentLifecycleState(STRING), jcr:nodeTypeName(STRING), jcr:isMixin(BOOLEAN), name(STRING), jcr:messageId(STRING), jcr:uuid(STRING), jcr:multiple(BOOLEAN), jcr:title(STRING), jcr:onParentVersion(STRING), mode:nodeTypeName(STRING), jcr:supertypes(STRING), jcr:protocol(STRING), mode:propertyName(STRING), jcr:frozenPrimaryType(STRING), jcr:lockOwner(STRING), jcr:createdBy(STRING), jcr:isDeep(BOOLEAN), jcr:hold(STRING), jcr:configuration(STRING), jcr:description(STRING), jcr:statement(STRING), mode:isHeldBySession(BOOLEAN), mode:workspaces(STRING), jcr:copiedFrom(STRING), jcr:retentionPolicy(STRING), jcr:root(STRING), jcr:versionableUuid(STRING), mode:generated(BOOLEAN), mode:localName(STRING), mode:id(STRING), mode:depth(LONG), jcr:score(DOUBLE), jcr:path(STRING), jcr:name(STRING)]> Index [custom] <INDEX_SPECIFICATION=custom2_names, provider=local, cost~=100, cardinality~=0, selectivity~=NaN, constraints=[NAME(custom) = 'myFirstBook'], INDEX_USED=true> Index [custom] <INDEX_SPECIFICATION=custom_names, provider=local, cost~=100, cardinality~=1, selectivity~=1.0, constraints=[NAME(custom) = 'myFirstBook']> Result columns: custom.[jcr:title] custom.[jcr:description] custom.[mode:localName] custom.[mode:id] custom.[mode:depth] custom.[jcr:score] custom.[jcr:path] custom.[jcr:name]
As you can see the plan is selecting the custom2_names index even though it is not the best one.