First of all you should be aware of "\dt+", which gives us the size of a table and "\d+" which describes a table. The "+" suffix adds more info to the descriptions.
CREATE TABLE foo AS SELECT '{"f":true}'::jsonb FROM generate_series(1,1e6);
CREATE TABLE bar AS SELECT '{"f":true}'::text FROM generate_series(1,1e6);
\dt+ foo;
\dt+ bar;
We see that the text field takes about half of the size of the jsonb. So if you don't need json features in a field (you're only archiving data that happens to be json), think twice when giving it the jsonb type.
Jsonb is TOAST-able, but will probably be toasted (and compressed) when it's bigger than a page, so don't count on that if you're jsons are <4kb .="" p="">
References:
4kb>
- https://dba.stackexchange.com/questions/161864/do-long-names-for-jsonb-keys-use-more-storage
- https://stackoverflow.com/questions/23120072/how-to-check-if-toast-is-working-on-a-particular-table-in-postgres
- https://postgrespro.com/list/thread-id/1849114
So, don't think spacewise it comes for free. If you're concerned about space, there's a big impact on the size of the table.
No hay comentarios:
Publicar un comentario