Cockroach: sql: allow ARRAYs in forward indexes

Created on 20 Jul 2017  路  9Comments  路  Source: cockroachdb/cockroach

Arrays support inverted indexes, but not forward indexes. If you want to index arrays, starting in CockroachDB 20.1 consider using an inverted index on your column.

This issue tracks adding forward indexes to array types.

A-sql-encoding C-enhancement O-community X-anchored-telemetry

Most helpful comment

You should definitely implement it. :)

All 9 comments

You should definitely implement it. :)

Any chance that this will be implemented?

It's not currently planned for a release, it's on my to-do list to look into when I get some free time - can't promise anything at the moment though.

Out of curiosity, do you have any details on what you would use this for?

Sure. Currently I have two use cases:

  1. tagging messages with labels (like important, later etc) and searching for messages which have a label or labels. Labels here are mostly strings or enums (a limited set which can grow in time).
  2. tagging objects with location IDs. There can be a limited (but variable in the range of 1 to tens) number of locations for each object. Some have only one, some more. The location IDs here are numbers (integers). I want to search for objects which live on a given location ID. There can be millions-billions of them, so I want to page on the result set (of course maintaining consistency, so between the start and the end of the search, the result set should be consistent, fixed)

You should definitely implement it. :)

My use case for this is storing all email addresses associated with each email I load into the DB. I want to be able to search for all messages associated with one email address.

Arrays are now indexable via inverted indexes, which supports containment operations on the arrays. We still don't support ordinary forward indexes on arrays.

@rohany @RaduBerinde I think the recent key encoding for arrays will solve this issue?

(sorry I put this comment on an unrelated issue about JSON - this is the one about arrays)

Yup, I've marked that PR as closing this (#48045)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richardanaya picture richardanaya  路  3Comments

xudongzheng picture xudongzheng  路  3Comments

intech picture intech  路  3Comments

danhhz picture danhhz  路  3Comments

rafiss picture rafiss  路  3Comments