PostgreSQL Architecture

Friday, 9 August 2013
PostgreSQL Architecture

Hello all,

Today I decided to write a blog on PostgreSQL architecture.
Off course, PostgreSQL has not defined its architecture in any of its Official documents. But this is a depiction / attempt from the way PostgreSQL internally works.
So this cannot be 100% right and All the valid corrections are truly welcome.

Lets start with the Architecture


Please note - The above diagram is courtesy of  http://raghavt.blogspot.in/2011/04/postgresql-90-architecture.html and I have learned a lot from his blogs.
The flow of processes can be seen in the Diagram above.
Lets understand each process, as to what they do.



Client Server (psql)

►Comprised of two main parts: the client application and the client interface library.

►Postgres comes prepackaged with its command line interface called psql

►Many different client applications, many of which run on different OS's, some include: Mergeant, PGInhaler, SQirreL and more.

►Client interface library is the way that each of those applications can talk to the Postgres Server because the client interface library will convert to the proper SQL queries that the server can understand and parse.

►This maximizes cohesion by the Postgres server not having to parse different languages, but only understand SQL queries, which makes the whole system faster.



Postmaster

►Is a daemon thread that runs constantly.

►Uses an implicit invocation architecture to listen for any and all calls to the database.

►When it receives a call from a client(psql or any other), it creates a back-end process (Postgres server) to match it, using 1-1 correspondence.

►Once the process is created, it links the postgres client and postgres process so that they no longer have to communicate through the Postmaster.



Postgres Back-end server process

►is responsible for executing the queries by the client.

►can handle only a single query at a time.

►to execute in parallel, an application must maintain multiple
connections to the server.

►back-end server can be executing concurrently.

►access DB data through the main-memory buffer pool as a shared
memory to have same view of data.

There are more utility process which still need to be explained,but for those processes you need to visit Raghav's link http://raghavt.blogspot.in/2011/04/postgresql-90-memory-processes.html
He has written the blog on memory and processes beautifully and is a must read for everybody, who is planning to understand internals of PostgreSQL.

Hope you all find this post useful and informative.

Read more ...