Paul Ramsey lays out the facts and the data:
Working with APIs and arrays in the
jsonbtype has become increasingly popular recently, and storing pieces of application data usingjsonbhas become a common design pattern.But why shred a JSON object into rows and columns and then rehydrate it later to send it back to the client?
The answer is efficiency. Postgres is most efficient when working with rows and columns, and hiding data structure inside JSON makes it difficult for the engine to go as fast as it might.
Read on to learn how Postgres manages to store arbitrary-sized JSONB data within the limitations of 8KB pages, and the performance implications of doing so.