hstore is generally a good solution for this, but personally, I prefer to use public key tables: value. One table with definitions, another table with values ββand relation to the values ββof the binding to the definition and relation to the values ββof the binding to a specific record in another table.
Why am I against hstore? Because it looks like a registry template. Often referred to as an example of an anti-pattern. You can put something there, it is difficult to easily check if it is still necessary, when loading an entire line (especially in ORM), the whole hstore is loaded, which can make a lot of unwanted and very little sense. Not to mention the need to convert the hstore data type to your language type and convert back when saving. This way you get some type conversion overhead.
So I'm actually trying to convert all hstores into the company I work for for simple value tables :. This is not so difficult because the structures stored here in hstore are huge (or at least large), and reading / writing an object breaks up huge overhead function calls. So a simple task like "select * from base_product, where id = 1;" makes a server sweat and severely impacts performance. You want to point out that the performance problem is not because db, but because python has to convert the results received from postgres several times. Although the key: value does not require such a conversion.
source share