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

opt: generate inverted index scans for JSON fetch value and containment operators #55318

Closed
mgartner opened this issue Oct 8, 2020 · 2 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) docs-done docs-known-limitation T-sql-queries SQL Queries Team

Comments

@mgartner
Copy link
Collaborator

mgartner commented Oct 8, 2020

CRDB previously generated inverted index scans for queries with filters like j->'a' @> '{"b": "c"}'. In order to generate these scans, it relied on normalization rules that converted the filters into JSON containment expressions, with the @> operator.

These normalization rules had to be removed in #55316 because they were found to produce inequivalent expressions. While #55316 re-added some support for index acceleration of filters with the -> operator, it did not cover this particular type of filter.

@mgartner mgartner added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Oct 8, 2020
@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@rytaft
Copy link
Collaborator

rytaft commented Jul 23, 2021

cc @ianjevans I added the "docs-known-limitation" tag to document that we cannot generate inverted index scans for queries with filters that have JSON fetch value and containment operators (e.g., j->'a' @> '{"b": "c"}') on 20.2 or 21.1. This was possible in 20.1 and before, but it caused other issues (see above for details). The full issue will be fixed on 21.2, but we do not plan to backport the fix to 20.2 or 21.1, since it is too risky. On 20.2 and 21.1, various other workarounds are available. For example, the filter j @> '{"a": {"b": "c"}}' produces the same results as j->'a' @> '{"b": "c"}', and it can be index-accelerated.

@mgartner
Copy link
Collaborator Author

This has been fixed on master by #63048. See @rytaft's comment above for details. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) docs-done docs-known-limitation T-sql-queries SQL Queries Team
Projects
None yet
Development

No branches or pull requests

4 participants