Sobes.tech
Middle+

Postgres with JSONB — can it be used as NoSQL?

sobes.tech AI

Answer from AI

Postgres with JSONB can indeed be used as a NoSQL solution, since JSONB allows storing and indexing semi-structured data within a relational database. This provides schema flexibility, characteristic of NoSQL, while maintaining the advantages of SQL — transactions, complex queries, and reliability.

However, consider:

  • JSONB is not a full-fledged NoSQL database, but an extension in a relational DBMS.
  • For complex hierarchies and large volumes of data, NoSQL might be more effective.
  • JSONB indexing supports GIN and other index types, which speeds up key and value searches.

Example query with JSONB:

SELECT * FROM users WHERE data->>'city' = 'Moscow';

Thus, Postgres with JSONB is a hybrid approach, suitable if you need the structure and power of SQL with the ability to work with dynamic data.