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

COUNT(*) on system:indexes can return incorrect results

    XMLWordPrintable

Details

    • Untriaged
    • 0
    • Unknown

    Description

      This is a server ticket for https://couchbasecloud.atlassian.net/browse/AV-69973

      Repro steps:

      1. Load travel-sample dataset

      2. Run the following queries:

      a. 

      select * from system:indexes
      

      The result count of the above query:

      "resultCount": 23

       

      b. Run a COUNT() against system:indexes without a predicate.

       

      select count(*) from system:indexes;
      

       

      The result is:

       

      [
          {
              "$1": 34
          }
      ]
      

       

       

      This is because the Count() implementation of the system:indexes keyspace does the following:

       

      1. In 7.6.0 onwards - Counts the primary index on the _system._query collection ( which is not included in system:indexes)

       

      2. Counts the indexes created on the bucket i.e on the bucket’s default._default collection - _twice.

      Since the Object is a keyspace and a bucket.

      https://github.com/couchbase/query/blob/8de352393a1cb1a9c41d0bd1e6de9288dc9b663a/datastore/system/system_keyspace_indexes.go#L113

      https://github.com/couchbase/query/blob/8de352393a1cb1a9c41d0bd1e6de9288dc9b663a/datastore/system/system_keyspace_indexes.go#L141

      Attachments

        Issue Links

          For Gerrit Dashboard: MB-60260
          # Subject Branch Project Status CR V

          Activity

            People

              pierre.regazzoni Pierre Regazzoni
              dhanya.gowrish Dhanya Gowrish
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty