Postgres SQL Compilation process

Source: Internet
Author: User

PG Start first completes the main process and background process start, the start of the completion of the database file opening, the establishment of shared memory and so on. Next, all SQL initiates 1 separate processes to process the SQL execution.

The new process begins with its own initialization, mostly by initializing the memory context and preparing the SQL process.

After entering the Postgresmain, parse the client command line parameters dbname, do the initialization of the file, store, cache, set the appropriate signal processing handle, call the Initpostgres method to initialize the Portgres service process, This method initializes the Relcache and Catcache, initializes the manager of the portal that executes the query plan, populates the PGPROC structure-related members of the process, and so on. Enter an infinite loop to check and process any requests or recently received signals. And then loop again.

The cycle has been readcommand. After entering an infinite loop, switch to the memory context "Messagecontext" and clean up the memory contexts, read the client commands, and process them separately according to the various commands of the client.

The client initiates the request, and the PG server initiates a postgres access process for that request, which establishes a connection for that client through access. This postgres access process enters an infinite loop, waits for the client to request and pass the service for it until the process terminates, connecting the fracture.

After the client has issued a query SQL to the server, the Postgres service process that has been started when the connection is made and enters the infinite loop server side processes the following steps:

(1) Call Memorycontextswitchto to switch the memory context to "Messagecontext".

(2) Call Memorycontextresetanddeletechildren to clean up the objects that were left in the "Messagecontext" memory context when the same connection service was last.

(3) Call Readcommand to read the client's request.

(4) According to the client request to determine what services to provide, into the corresponding branch.

Postgres SQL Compilation process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.