Postgresql: NoSQL for relational databases

Postgres is a well-known open source relational database with a long history and has always been known for its excellent performance; the complete support for spatial database (PostGIS) is even more admirable. Starting with Postgres 9.x, Postgres has added exciting NoSQL support. Postgres mainly has the following characteristics:

  • Mature
  • fast
  • Extended plugin ecology
  • ACID compliant
  • Support for unstructured NoSQL storage
  • Support relational storage
  • NoSQL and relational data can be combined
  • Built-in full-text search

Postgres implements document storage by adding a json (jsonb) data type.

We can create a new Person table with an id field and an info field, where the data type of the info field is jsonb:

Add json data for the current table:

json query:

Query for people whose age is 20:

  1. select * from"Person"where info @>'{"age":20}'

 

Look for people with "上" in the address:

  1. select * from"Person"where info ->> 'address'like'%上%'

 

Through the simple demonstration in this article, we realized the NoSQL support of Postgres, which provides support for the application scenarios we encountered in application development when the data structure is not fixed; however, we are the best in applying NoSQL as data storage. The application scenario is: the data conforms to the principle of "write once and read many times".

 

If the code is not clear, please check http://www.microinsight.cn/2015/11/24/postgres-nosql/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327041229&siteId=291194637