Suppose I have a Postgres database with some HStore columns. What is it's effect on performance? Especially if most queries are run without examining the HStore attributes, would the fact that there are HStore attributes slow it down significantly?
In storage terms hstore
is just another variable length field, like bytea
or text
. It's TOAST
able for out-of-line storage, compressible, etc.
When you're not accessing the hstore
column then the only concern is the extra size it adds to each row, making scans slower. This is mitigated by PostgreSQL storing bigger hstore
fields out-of-line in a TOAST table.
Like with a text
or other variable length column, if you update
the row the large column's contents must be copied because of PostgreSQL's copy-on-write concurrency control. However, if the column is not modified in the write and it's been stored out-of-line PostgreSQL can often get away with not copying it, and just copying a reference to it instead.
Generally having a hstore column won't have much effect on performance if it's not heavily used.