yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.99k stars 1.07k forks source link

Support local indexes #25

Open OmerCerrahoglu opened 6 years ago

OmerCerrahoglu commented 6 years ago

Implement local indexes.

Motivation

Provide better performance for queries with WHERE conditions that fully specify hash keys.

Requirements

A local secondary index is a distributed index. It has the following characteristics:

Initial plan is to implement this as:

Syntax

Auto-inferred when the index is created using the same hash partition keys as the table.

CREATE INDEX [IF NOT EXISTS] index_name
    ON [keyspace_name.]table_name ( (index_hash_column, ...), index_cluster_column, ... )
    [WITH CLUSTERING ORDER BY (index_cluster_column { ASC | DESC }, ...)]
    [COVERING (covered_column, ...)]
i((hash_columns (from original)), 

Note: we might not want/need to have covering columns, but I guess it can’t hurt (though I am currently not planning on using them in any way, though it shouldn’t be too hard to make use of them: just have the semantic analyzer understand if he index is enough to answer the query) Note: as the local index already uses the hash keys from the original table as hash keys, we might want not to allow any additional hash keys, but allowing it should not break anything.

Allow additional:

kmuthukk commented 6 years ago

moving this to your queue Robert for now.