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

Add list support to vindex functions #9426

Merged
merged 2 commits into from
Dec 22, 2021

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Dec 20, 2021

Description

This adds support for vindex function batch lookups using the IN SQL operator:

mysql> select * from customer.hash where id = 100;
+------+-------------+-------------+-----------+------------------+-------+
| id   | keyspace_id | range_start | range_end | hex_keyspace_id  | shard |
+------+-------------+-------------+-----------+------------------+-------+
| 100  | ���V��    | �           |           | 83aab1569cbe1b08 | 80-   |
+------+-------------+-------------+-----------+------------------+-------+
1 row in set (0.00 sec)

mysql> select * from customer.hash where id in (100,1,999);
+------+-------------+-------------+-----------+------------------+-------+
| id   | keyspace_id | range_start | range_end | hex_keyspace_id  | shard |
+------+-------------+-------------+-----------+------------------+-------+
| 100  | ���V��    | �           |           | 83aab1569cbe1b08 | 80-   |
| 1    | k@�J�K�    |             | �         | 166b40b44aba4bd6 | -80   |
| 999  | X���IH    |             | �         | 58afce9fbfe54948 | -80   |
+------+-------------+-------------+-----------+------------------+-------+
3 rows in set (0.00 sec)

mysql> select * from customer.hash where id like "5";
ERROR 1105 (HY000): unsupported: where clause for vindex function must be of the form id = <val> or id in(<val>,...) (not equality)

For more info about the use case, please see: #9042

Related Issue(s)

Fixes: #9042

Checklist

  • Should this PR be backported? I don't think so
  • Tests were added
  • Documentation is not required -- I could not find any documentation to modify for using the vindex functions???

Deployment Notes

@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Query Serving release notes labels Dec 20, 2021
@mattlord mattlord force-pushed the VIndexFuncQueryBatch branch 2 times, most recently from 8d7797a to d848f5a Compare December 20, 2021 21:05
@mattlord mattlord force-pushed the VIndexFuncQueryBatch branch from d848f5a to fec1266 Compare December 20, 2021 21:43
@mattlord mattlord marked this pull request as ready for review December 20, 2021 21:56
Comment on lines +332 to +336
"unsupported: where clause for vindex function must be of the form id = <val> or id in(<val>,...) (multiple filters)"
Gen4 plan same as above

"select keyspace_id from user_index where func(id)"
"unsupported: where clause for vindex function must be of the form id = <val> (not a comparison)"
"unsupported: where clause for vindex function must be of the form id = <val> or id in(<val>,...) (not a comparison)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can stop calling them unsupported, some of them do not seem reasonable queries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it in different PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean here. We should call some of them invalid?

go/vt/vtgate/engine/vindex_func_test.go Outdated Show resolved Hide resolved
go/vt/vtgate/engine/vindex_func_test.go Outdated Show resolved Hide resolved
go/vt/vtgate/engine/vindex_func.go Outdated Show resolved Hide resolved
@mattlord
Copy link
Contributor Author

Thanks for the good suggestions, @harshit-gangal ! I've addressed those here: 5af2d18

@harshit-gangal harshit-gangal merged commit a2fc06a into vitessio:main Dec 22, 2021
@harshit-gangal harshit-gangal deleted the VIndexFuncQueryBatch branch December 22, 2021 16:57
@mattlord mattlord mentioned this pull request Dec 22, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Batch Lookup With VIndex Functions in Planner
2 participants