23

Django 1.8 provides HStoreField and Django 1.9 will provide JSONField (which uses jsonb) for PostgreSQL.

My understanding is that hstore is faster than json, but does not allow nesting and only allows strings.

When should one be used over the other? Should one be preferred over the other? Is hstore still the clear winner in performance compared to jsonb?

mu is too short
  • 426,620
  • 70
  • 833
  • 800
mcastle
  • 2,882
  • 3
  • 25
  • 43

1 Answers1

21

If you need indexing, use jsonb if you're on 9.4 or newer, otherwise hstore. There's really no reason to prefer hstore over jsonb if both are available.

If you don't need indexing and fast processing and you're just storing and retrieving validated data, use plain json. Unlike the other two options this preserves duplicate keys, formatting, key ordering, etc.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778