Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

Does updating a jsonb column trigger updates on all expression indexes on that column?

$
0
0

I am using the jsonb type in PostgreSQL. I frequently make updates of the following kind (where jdoc is a jsonb column):

UPDATE my_table SET jdoc = jdoc || '{a: "Hello World!"}'::jsonb WHERE id = 123

I have a number of expression indexes on the jsonb column:

CREATE INDEX ix_b ON my_table some_function(jdoc->>b)
CREATE INDEX ix_c ON my_table some_other_function(jdoc->>c)

As you can see, I only change jdoc->a, but I have to set the whole jdoc column. Will I therefore suffer the full performance penalties of updating the indexes on jdoc->b and jdoc->c? Or is PostgreSQL smart enough to notice that those values did not change, and that the indexes therefor does not need to be updated? If I suffer the full performance penalty, is there any way to avoid it?


Viewing all articles
Browse latest Browse all 148

Trending Articles