Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

save config/settings into relational database (postgresql)

I'm building a feature where I have to get/save a config (something like a json structure) into db. So this postgresql jsonb data type came into my mind. Because this config doesn't have to be related to other table. coming from a nosql background, is my use case for jsonb correct? (I don't want to abuse this feature or use it wrongly)

Is this the right thing to do? Just to double confirm with experienced dev here before I start implementing it.

like image 502
Hanz Avatar asked Aug 31 '25 18:08

Hanz


1 Answers

That seems like a use case for jsonb or json.

These data types are useful to store information in the database that is of use for the application, but is not used much inside the database.

If you plan to use values from the JSON in queries, for example to join with other tables or to filter in WHERE clauses, you should consider storing these values as normal table columns (perhaps keeping the rest in a JSON).

While PostgreSQL has support for processing JSON inside the database, queries that make use of that a lot tend to become complicated and slow.

like image 184
Laurenz Albe Avatar answered Sep 02 '25 09:09

Laurenz Albe