Issue
This Content is from Stack Overflow. Question asked by Kevin
if you have data stored as json in a column, you could query the data by
select * from TABLE where json_column['name'] = 'Bob'
or
select * from TABLE where parse_json(json_column::variant):name:varchar = 'Bob'
Are these equivalent in performance?
Solution
No, they are not equivalent in performance, although they use a very similar path to access the "name" field.
- The first query can use metadata of JSON attributes, and you
may see a good partition pruning. - The second one will read all JSON data (whole partitions) and use
parse_json on the column before fetching the field.
In short, the first query is expected to be much faster on larger datasets.
This Question was asked in StackOverflow by Kevin and Answered by Gokhan Atil It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.