Home:ALL Converter>Best PostgreSQL datatype for storing key-value maps?

Best PostgreSQL datatype for storing key-value maps?

Ask Time:2017-04-07T00:41:46         Author:Eyal Roth

Json Formatter

I'd like to store a simple map of key-value strings as a field in my PostgreSQL table. I intend to treat the map as a whole; i.e, always select the entire map, and never query by its keys nor values.

I've read articles comparing between hstore, json and jsonb, but those didn't help me choose which data-type is most fitting for my requirements, which are:

  • Only key-value, no need for nesting.
  • Only strings, no other types nor null.
  • Storage efficiency, given my intended use for the field.
  • Fast parsing of the queried maps.

What data-type would best fit my use case?

Author:Eyal Roth,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43261128/best-postgresql-datatype-for-storing-key-value-maps