When you send a query to PostgreSQL, it will undergo several processing stages in the backend. Each of these stages has different responsibilities to

A Comprehensive Overview of PostgreSQL Query Processing Stages

submited by
Style Pass
2024-04-01 10:30:02

When you send a query to PostgreSQL, it will undergo several processing stages in the backend. Each of these stages has different responsibilities to ensure that you receive correct responses in shortest amount of time possible. Yes, they can be quite large and complex to fully understand but I believe it is important for PostgreSQL developer like you to at least understand their roles in handling a query. In this blog, I will give an overview of each query processing stage, their roles and significance in PostgreSQL architecture.

PostgreSQL’s parser is created using the lex (Flex lexical analyzer) and yacc (bison parser) tools. Both are commonly used tools. This is done usually by writing a regular expression definition file, which is then converted into the corresponding C source file structures. These generated source files can be found under src/backend/parser. This conversion action is automatically performed when executing Make when you compile PostgreSQL from source.

For example: table name, inserted data type, field name information will be checked for validity. If they exist, PostgreSQL will use the OID number to represent them internally and generate a query tree structure.

Leave a Comment