[GENERAL] performance considerations of jsonb vs separate rows

Поиск
Список
Период
Сортировка
От Rob Nikander
Тема [GENERAL] performance considerations of jsonb vs separate rows
Дата
Msg-id 34B9328E-F435-4460-A877-96F61AC62CEE@gmail.com
обсуждение исходный текст
Ответы Re: [GENERAL] performance considerations of jsonb vs separate rows  (Andreas Kretschmer <andreas@a-kretschmer.de>)
Re: [GENERAL] performance considerations of jsonb vs separate rows  (Dmitry Dolgov <9erthalion6@gmail.com>)
Re: [GENERAL] performance considerations of jsonb vs separate rows  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
Hi,

I’ve got a web app where I want to store user’s session data. The schema in this data changes a lot so it may be useful here to store the session properties in either a jsonb column, or in multiple rows. Something like:

  session_id | data 
  100          { a: 1, bar: 2 ...
  101          { a: 3, baz: 123 …

or

  session_id | name | value
  100          a      1
  100          bar    2
  101          baz    123
  101          a      3
  ... 

The app currently does something like option 1, but on an older pre-jsonb version of postgres, so the field is just text. I’m hoping to upgrade Postgres soon so jsonb is an option.

I'm wondering about the tradeoffs, specifically: is it possible to update one piece of a jsonb value without having to rewrite the entire field? There are cases where that data field was getting pretty big (500kb). Would you expect any obvious performance differences between these two options?

Yes, I’ll need to build performance tests myself, but that’s a lot of work to get two realistic situations with millions of rows, so I’m wondering about guesses or common knowledge on this.

thanks,
Rob

В списке pgsql-general по дате отправления:

Предыдущее
От: Bill Moran
Дата:
Сообщение: Re: [GENERAL] autovacuum holds exclusive lock on table preventingit from to be updated
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: [GENERAL] performance considerations of jsonb vs separate rows