Description
CREATE INDEX `def_name_type` ON `travel-sample`(`name`) WHERE (`_type` = "User");
Uses the index:
curl -v http://localhost:8093/query/service -d 'statement=EXPLAIN SELECT * FROM `travel-sample` where _type="User" and name=$name&$name="id@mail.com"'
Does not use the index:
curl -v http://localhost:8093/query/service -d 'statement=EXPLAIN SELECT * FROM `travel-sample` where _type=$type and name=$name&$type="User"&$name="id@mail.com"'
This is an adhoc query with paramters provided at the time of query submission.
This does not require a prepare-execute step.
Since we have the full information here, we should be able to substitute the value before optimization so we get the best possible index selection.
PREPARE statements will not use the index because we don't have full information to consider this index.
The following statement should able to push the array values in spans
curl -v http://Administrator:password@localhost:8093/query/service -d 'statement=EXPLAIN SELECT * FROM `travel-sample` where _type="User" and name IN $name&$name= ["id@mail.com", "id1@mail.com"]'