Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: support inverted indexes with more than one inverted column #91460

Open
Tracked by #59331
jordanlewis opened this issue Nov 8, 2022 · 0 comments
Open
Tracked by #59331

sql: support inverted indexes with more than one inverted column #91460

jordanlewis opened this issue Nov 8, 2022 · 0 comments
Labels
A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team

Comments

@jordanlewis
Copy link
Member

jordanlewis commented Nov 8, 2022

Currently, it's not possible to create a multi-column inverted index where more than one column is inverted:

[email protected]:26257/defaultdb> create table a (j1 json, j2 json);
CREATE TABLE

[email protected]:26257/defaultdb> create index on a using gin(j1, j2);
ERROR: column j1 of type jsonb is only allowed as the last column in an inverted index
SQLSTATE: 0A000
HINT: see the documentation for more information about inverted indexes: https://www.cockroachlabs.com/docs/v22.2/inverted-indexes.html

However, this is possible in Postgres:

jordan=> create table a (j1 jsonb, j2 jsonb);
CREATE TABLE
jordan=> create index on a using gin(j1, j2);
CREATE INDEX

Having more than one inverted column would improve the selectivity of the index in some cases, such as a situation with two trigram indexes on two separate text columns in the same table.

For example, see this comment #41285 (comment)

Jira issue: CRDB-21271

@jordanlewis jordanlewis added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-optimizer SQL logical planning and optimizations. A-sql-execution Relating to SQL execution. labels Nov 8, 2022
@michae2 michae2 added the T-sql-queries SQL Queries Team label Oct 6, 2023
@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Oct 6, 2023
@michae2 michae2 moved this from Triage to New Backlog in SQL Queries Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
Status: Backlog
Development

No branches or pull requests

2 participants