Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-24871

Improve optimization for adhoc queries with parameters.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.6.3, 5.0.0
    • 4.5.1, 4.6.2
    • query
    • None

    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"]'

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Prerna.Manaktala Prerna Manaktala (Inactive)
              keshav Keshav Murthy
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty