1

I'm trying to find the name for these type of indexes. I looked on Google and Postgres documentation and they have nothing on what Value-> operator does. And how its different from a regular: -> SomeInt.

CREATE INDEX "someIndex" ON "me-db"."someTable" USING btree ((((jsondata -> 'SomeInt'::text) -> 'HasValue'::text)))
CREATE INDEX "someIndex2" ON "me-db"."someTable" USING btree ((((jsondata -> 'SomeInt'::text) -> 'Value'::text)))

What are the names for ->HasValue and ->Value operators? How is ->Value different from ->Field.

2 Answers 2

1

These are the key names in you json structure. If you wrap one with another it means you have a nested json like this (for the above lines):

{"SomeInt": {"HasValue": 1, "Value": 2}}

Sign up to request clarification or add additional context in comments.

1 Comment

We had a bug on code that created indexes on the fly. And we have a nullable type, and it created Value, HasValue indexes (reflectively looking at a nullable type) and thats it. We understand this now, thanks!
0

Those are called expressional or (more commonly but less correctly) functional indexes.

You are not using ->Value, you are using ->'Value'. Those are different things. The fist would be looking for a column named "value", and using its contents as the name of the key to look for. The second uses the literal string 'Value' as the name of the key to look for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.