I'm looking at using PostgreSQL's jsonb
column type for a new backend project that will mainly serve as an REST-ful JSON API. I believe that PostgreSQL's jsonb
will be a good fit for this project as it will give me JSON objects without need for conversion on the backend.
However, I have read that the jsonb
data type slows down as keys are added, and my schema will have need of using primary keys and foreign key references.
I was wondering if having primary keys/foreign keys in their own columns (in the standard relational database way) and then having a jsonb
column for the rest of the data would be beneficial, or would this cause problems (whether now or down the road)?
In short, would:
table car(id int, manufacturer_id int, data jsonb)
perform better or worse than:
table car(data jsonb)
Especially when looking up foreign keys frequently?
Would there be downsides to the first one, from a performance or a schema perspective?