Roughly how fast is JSON -> JSONB column conversion in Postgres 9.4

混江龙づ霸主 提交于 2019-12-07 00:24:46

问题


I'm looking to migrate from Postgres 9.3 to 9.4, and have a lot of data in JSON columns. While it's fine, I wanted to have a look at migrating to the more efficient column storage (which JSONB seems to be — a really exciting piece of tech!).

To actually migrate, I want to know migration characteristics for something like

ALTER TABLE table_with_json
    ALTER COLUMN my_json
    SET DATA TYPE jsonb
    USING my_json::jsonb;

(from this helpful question).

Ideally, it would be good to know how long it takes to migrate 1mil and 10mil entries, and how it scales.

While I can get these numbers myself, I thought this question might be helpful for others. If I end up trying this out myself, I'll be sure to provide an answer for others, but not sure when that'll happen.


回答1:


Migrating from JSON to JSONB took 282 seconds. It basically matches the time required to insert data with an SQL INSERT.

Testing environment:

  • PostgreSQL 9.5
  • 4 cores, 16GB RAM
  • 2KB/row of JSON content
  • 5.2 million rows



回答2:


Some back-of-the napkin numbers for a test instance migration:

  • PostrgeSQL 9.6
  • 2 vcpu cores, 8GB RAM, EBS max bandwith 450 MBit/s
  • 930K rows
  • 20KB/row of json

Took 66:40min - 4000 seconds.
During the migration the write IOPS were around 250, read at 50, cpu stayed at 60% throughout the run.



来源:https://stackoverflow.com/questions/34042429/roughly-how-fast-is-json-jsonb-column-conversion-in-postgres-9-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!