Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ PostgreSQL Select source code analysis     - Nginx introduced Dynamic Module Architecture (Server)

- How to handle special characters in JSON (Programming)

- Ant command-line compiler Android project (Programming)

- Ubuntu install virtual machine software VirtualBox 4.3.10 (Linux)

- How to create an alternative Android / iOS connected wireless hotspot AP in Ubuntu 15.04 (Linux)

- Getting Started with Linux system to learn: how to check in a package is installed on Ubuntu (Linux)

- Cacti monitoring service Nginx (Linux)

- Difference LVS three scheduling modes (Server)

- Linux Kernel 4.2.2 compiler installation tutorial (Linux)

- Linux input and output redirection (Linux)

- Ubuntu install video playback software SMPlayer 14.9.0.7042 (Linux)

- Ubuntu 14.04 LTS to compile the source code Android4.4.2 (Linux)

- Upgrade Goldengate 11.1.1.1.2 to 11.2.1.0.1 (Database)

- Understand the security restore accidentally deleted critical system files (Linux)

- Source encountered problems and solutions when installing SaltStack (Server)

- Findbugs installation documentation (Linux)

- Linux terminal interface font color settings (Linux)

- Spring AOP for logging (Programming)

- Sublime Text Add instructions to insert the current time zone (Linux)

- Analysis of potential problems through custom Orabbix monitoring Oracle (Database)

 
         
  PostgreSQL Select source code analysis
     
  Add Date : 2017-08-31      
         
         
         
  The client initiates the SQL statement, and the PG server process backend receives the statement and begins executing the exec_simple_query () code. Behind all method calls are exec_simple_query () function directly or indirectly initiated.

Generally divided into the following process: pg_parse_query () -> pg_analyze_and_rewrite () -> pg_plan_queries () -> ... ExecutePlan () ... -> pg_report_stat ().

Pg_parse_query

But simply generate raw parse tree, which does not involve semantic checks. Just do a grammar scan that is a Bison parser.

Pg_analyze_and_rewrite

This will be a semantic analysis, will visit the database of objects, the need to hold locks. This process splits a simple select statement into multiple parts, transforming the parse tree into a query tree. Such as the entire select statement into: from part,

Where condition part, group by part, order by part and having part and so on. Is the need for any database operation, and a very important part.

Pg_plan_queries

In this session, will be based on the query tree above to generate the implementation plan. This part of the core code in planner.c, the PG Query Optimizer. Will be based on the table and the index of statistical information to calculate the possible cost of different paths, and finally select the best.

Here will not start, the back will write an article, specifically about this piece, the "PG Cost-based Optimizer principle."

ExecutePlan

Execute plan, which iterates through each node so that it completes. Finally, the query results returned to the client.

Pg_report_stat

The statistics are sent to the collector. Such as how many times the table and index have been scanned, how many records have been returned, and so on. If the DML statement, there will be additions and deletions in addition to change the number of records of statistical information. The original information is in the form of a table, which is later aggregated to the library level or the instance level.

This is important for health checks or for monitoring PG performance.

From the timing diagram below, it can be seen that the task of each source file is very clear.

Postgres.c: for the backend process, responsible for miscellaneous and scheduling, and the client is the corresponding server process. Because the PG is C / S architecture, each client to connect to the PG, postmaster will fork out a backend process to interact with.

Xact.c: is a transaction-related operation. The status flag of the transaction, the isolation level, whether there are nested transactions, and so on.

Utility.c: statement or command type, including delete, insert, update, select, explain, create, alter and so on.

ExecMain.c: is the total schedule entry for the execution statement.

Pgstat.c: responsible for database statistics collection and display.

Portalmem.c: responsible for the implementation of the statement, the memory application and release. PG, specifically take a name called portal, the equivalent of workspace.
     
         
         
         
  More:      
 
- Timeout control related to Python threads and a simple application (Programming)
- C # function (Programming)
- How to use the Linux terminal Git commands (Linux)
- PHP loop reference caused strange problems (Programming)
- History and Statistics tuptime use tools to view Linux server system boot time (Server)
- Ubuntu 14.10 Apache installation and configuration (Server)
- Recent Consolidation Using Linux security module (Linux)
- Use Docker containers (Linux)
- Smack 4.1.x Upgrade Guide (Linux)
- RedHat Linux source code package installation process (Linux)
- Enterprise Hadoop cluster architecture - NFS installation (Server)
- Linux system font color change (Linux)
- PHP file upload methods exist in the database (Programming)
- Learning UNIX good habits (Linux)
- Use PXE with kickstart to install Linux automatically (Linux)
- MySQL Tutorial: About checkpoint mechanism (Database)
- Why do I prefer Git (Linux)
- Setting Squid successful anti-hotlinking (Linux)
- 14.04.3 Ubuntu configuration and successfully compiled source code Android 6.0 r1 (Programming)
- Ubuntu in Vim editor display processing method Chinese garbled (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.