-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 expression-based index columns #9682
Comments
Would help with #7186 too. |
This is one of the top unimplemented errors encountered by users |
petition |
We are hitting this also, some advance on this would be appreciated. |
Moving to Optimizer backlog, cc @RaduBerinde @mgartner |
This is tracked by #24455. |
I'm sorry you can't close an issue that's X-anchored-telemetry until the feature is complete and references to the issues in the code have been removed. |
Copying over comment some recent info from #24455 below. I did a bit of research of what work would be necessary to support expression-based indexes:
Some aspects would be simplified if we treated the expressions as virtual columns (computed but not stored) throughout the stack, but other aspects would become more complicated (it would be the first non-scannable table column - and the code around different kinds of table columns is already very complex). Overall the amount of work is on the same order of magnitude as partial indexes. |
@RaduBerinde any updates on this? We need to apply an expression-based unique index to ensure unicity over a JSON field like, in PostgreSQL you could do:
But in CRDB, until this is solved, we are planning to replicate the columns in the parent tablet by using a computed field:
Then apply the UQ over it:
|
@lopezator We've begun implementing expression-based indexes, but the feature won't be released until the 21.1 release at the earliest (Spring 2021). Until then, I think the workaround you mentioned is your best option. |
Checking in on this - looks like #57608 shipped late last year. Any plans to move forward with this? I think this is the only remaining issue prevent the Livepeer API server from using Cockroach. |
Yes, we have plans to support the syntax in 21.2. Note that in 21.1 (which is close to be released) we support virtual columns which allow you to do the same thing essentially. |
Expression indexes have landed on |
Heads up, the following does not seem to work yet
returns:
Seems it's related to 2bb519e#diff-606ca467041f6ba1f19e8ef8530d2976bf9b0db98477940ae9deb7b2fd5d1795L363 which would land on v22 |
@renevall sounds like you haven't finished the upgrade to v21.2. https://www.cockroachlabs.com/docs/stable/upgrade-cockroach-version.html |
Computed indexes are indexes on the result of an expression (as opposed to the direct value of a column). For example:
CREATE INDEX a ON customer( LOWER(firstname) || ' ' || LOWER(lastname))
Suggested by @petermattis
The text was updated successfully, but these errors were encountered: