-
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 more index-type combinations #35730
Comments
Hello, my team are using CockroachDB in production and are finding it great so far. Our current use-case for wanting to index array fields is fairly simple. We have a store of personal information where each row has a When we add new people to this table we want to check in advance if one of their phone numbers is already in use by someone else. So we have a query like:
Without indexing it takes around 3 seconds per phone number we search where there are ~450k rows. In some instances, someone could be added who has many phone numbers, or many people who have many phone numbers, which we would individually check, leading to a linear increase in query time. Perhaps we are approaching this problem incorrectly, but I suspect being able to index this field would yield faster queries. |
cc @awoods187 @andy-kimball for triage |
Hi Team, |
cc @jordanlewis |
The two requests in this thread are for inverted indexes on arrays. Filed #43199 to track this. |
We use an internal unique id for a user. For transactions in the system can affect multiple users, so each transaction logged may have multiple users affected and we look which ones the transaction is applied to. (Usually less than 10). We have millions of users and billions of transactions to log. Not bring able to index on an array has kept me from trying cockroach. |
Arrays are now indexable with inverted indexes. |
I ran into this today for VARCHAR and updated the issue at the top to track |
Hi,
Is it still planned for 20.2? I'm getting
against cockroachdb/cockroach-unstable:v20.2.0-rc.1 |
@jordanlewis I think you know most about inverted indexes on arrays, can you take a look at the question above> |
@RaduBerinde we do support inverted indexes on arrays. @jdabrowski correctly points out that we do not support forward indexes on arrays, despite what I said above. We ran into some issues that prevented us from getting them into 20.2 after all. |
@jordanlewis thanks for the answer |
We have an issue here with an optimised data storage for placing trades that contain several sub-components. There need to be two arrays on the object.
The query is made for a market event and corresponding correct outcome.
10000 is the id of the market |
@bryanhuntesl you should be able to create two inverted indexes on the two arrays (or only one, for the more restrictive condition). |
Thanks, @RaduBerinde. I have verified the scenario works with the latest pre-release version (v21.1.0-beta.2). Executing the following : CREATE TABLE positions (pos VARCHAR[]);
CREATE INDEX pos_index ON positions USING GIN (pos);
INSERT INTO positions VALUES (ARRAY['ln-std:1,10,30' ]);
EXPLAIN SELECT * FROM positions WHERE pos @> ARRAY['ln-std:1,10,30'];
|
any chance to support for varchar inverted indexes? |
I think now you can do some form of this with a computed expression over the varchar field which you can get with either a virtual computed column in 21.1 or an expression based index in the upcoming 21.2. |
Looks like only inverted indexes on VARCHAR is left in this meta issue. We're going to check if there is any code pointing to this issue number, and potentially close this issue. |
We still use this issue for telemetry. Moving to backlog. |
The following combinations are not supported:
This is a meta issue filed for tracking and telemetry purposes.
To users who are inconvenience: please leave comments with an explanation of your use case.
Jira issue: CRDB-4560
The text was updated successfully, but these errors were encountered: