From 5e45211a64149b3c659b90ff2de6fa982a5a93ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:17:33 +0200 Subject: Adding upstream version 15.5. Signed-off-by: Daniel Baumann --- doc/src/sgml/html/query-path.html | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/src/sgml/html/query-path.html (limited to 'doc/src/sgml/html/query-path.html') diff --git a/doc/src/sgml/html/query-path.html b/doc/src/sgml/html/query-path.html new file mode 100644 index 0000000..e8efce7 --- /dev/null +++ b/doc/src/sgml/html/query-path.html @@ -0,0 +1,55 @@ + +52.1. The Path of a Query

52.1. The Path of a Query

+ Here we give a short overview of the stages a query has to pass + to obtain a result. +

  1. + A connection from an application program to the PostgreSQL + server has to be established. The application program transmits a + query to the server and waits to receive the results sent back by the + server. +

  2. + The parser stage checks the query + transmitted by the application + program for correct syntax and creates + a query tree. +

  3. + The rewrite system takes + the query tree created by the parser stage and looks for + any rules (stored in the + system catalogs) to apply to + the query tree. It performs the + transformations given in the rule bodies. +

    + One application of the rewrite system is in the realization of + views. + Whenever a query against a view + (i.e., a virtual table) is made, + the rewrite system rewrites the user's query to + a query that accesses the base tables given in + the view definition instead. +

  4. + The planner/optimizer takes + the (rewritten) query tree and creates a + query plan that will be the input to the + executor. +

    + It does so by first creating all possible paths + leading to the same result. For example if there is an index on a + relation to be scanned, there are two paths for the + scan. One possibility is a simple sequential scan and the other + possibility is to use the index. Next the cost for the execution of + each path is estimated and the cheapest path is chosen. The cheapest + path is expanded into a complete plan that the executor can use. +

  5. + The executor recursively steps through + the plan tree and + retrieves rows in the way represented by the plan. + The executor makes use of the + storage system while scanning + relations, performs sorts and joins, + evaluates qualifications and finally hands back the rows derived. +

+ In the following sections we will cover each of the above listed items + in more detail to give a better understanding of PostgreSQL's internal + control and data structures. +

\ No newline at end of file -- cgit v1.2.3