Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b15e7df8
Commit
b15e7df8
authored
Jun 28, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backend update.
parent
8986e609
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
47 deletions
+44
-47
src/tools/backend/index.html
src/tools/backend/index.html
+44
-47
No files found.
src/tools/backend/index.html
View file @
b15e7df8
...
@@ -8,30 +8,30 @@ PostgreSQL Backend Flowchart
...
@@ -8,30 +8,30 @@ PostgreSQL Backend Flowchart
</H1>
</H1>
<H2
ALIGN=
CENTER
>
<H2
ALIGN=
CENTER
>
by Bruce Momjian
by Bruce Momjian
</H2
ALIGN=CENTER
>
</H2>
<P>
<P>
Queries
come into the backend via data packets coming in through TCP/IP
A query
come into the backend via data packets coming in through TCP/IP
and Unix Domain sockets.
They are
loaded into a string, and passed to
and Unix Domain sockets.
It is
loaded into a string, and passed to
the
the
<A
HREF=
"../../backend/parser"
>
parser,
</A>
where the lexical scanner,
<A
HREF=
"../../backend/parser"
>
parser,
</A>
where the lexical scanner,
<A
HREF=
"../../backend/parser/scan.l"
>
scan.l,
</A>
<A
HREF=
"../../backend/parser/scan.l"
>
scan.l,
</A>
breaks the query up into tokens(words). The parser
breaks the query up into tokens(words). The parser
uses
uses
<A
HREF=
"../../backend/parser/gram.y"
>
gram.y
</A>
and the tokens to
<A
HREF=
"../../backend/parser/gram.y"
>
gram.y
</A>
and the tokens to
identify the query type, and load the proper query-
type-
specific
identify the query type, and load the proper query-specific
structure, like
structure, like
<A
HREF=
"../../include/nodes/parsenodes.h"
>
CreateStmt or SelectStmt.
</A>
<A
HREF=
"../../include/nodes/parsenodes.h"
>
CreateStmt or SelectStmt.
</A>
<P>
<P>
The query is then identified as a
<I>
Utility
</I>
function or a more
The query is then identified as a
<I>
Utility
</I>
function or a more
complex query.
<I>
Utility
</I>
queries are
processed by a
complex query.
A
<I>
Utility
</I>
query is
processed by a
query-
type-
specific function in
<A
HREF=
"../../backend/commands"
>
query-specific function in
<A
HREF=
"../../backend/commands"
>
commands.
</A>
Complex queries, like
<I>
SELECT, UPDATE,
</I
>
and
commands.
</A>
A complex query, like
<B>
SELECT, UPDATE,
</B
>
and
<
I>
DELETE
</I>
require much more handling.
<
B>
DELETE
</B>
requires much more handling.
<P>
<P>
The parser takes
the complex queries
, and creates a
The parser takes
a complex query
, and creates a
<A
HREF=
"../../include/nodes/parsenodes.h"
>
Query
</A>
structure that
<A
HREF=
"../../include/nodes/parsenodes.h"
>
Query
</A>
structure that
contains all the elements used by complex queries. Query.qual holds the
contains all the elements used by complex queries. Query.qual holds the
WHERE
clause qualification, which is filled in by
<B>
WHERE
</B>
clause qualification, which is filled in by
<A
HREF=
"../../backend/parser/parse_clause.c"
>
transformWhereClause().
</A>
<A
HREF=
"../../backend/parser/parse_clause.c"
>
transformWhereClause().
</A>
Each table referenced in the query is represented by a
<A
Each table referenced in the query is represented by a
<A
HREF=
"../../include/nodes/parsenodes.h"
>
RangeTableEntry,
</A>
and they
HREF=
"../../include/nodes/parsenodes.h"
>
RangeTableEntry,
</A>
and they
...
@@ -39,33 +39,32 @@ are linked together to form the <I>range table</I> of the query, which is
...
@@ -39,33 +39,32 @@ are linked together to form the <I>range table</I> of the query, which is
generated by
<A
HREF=
"../../backend/parser/parse_clause.c"
>
generated by
<A
HREF=
"../../backend/parser/parse_clause.c"
>
makeRangeTable().
</A>
Query.rtable holds the queries range table.
makeRangeTable().
</A>
Query.rtable holds the queries range table.
<P>
<P>
Certain queries, like
SELECT, return columns of data. Other queries,
Certain queries, like
<B>
SELECT,
</B>
return columns of data. Other
like INSERT and UPDATE, specify the columns modified by the query.
queries, like
<B>
INSERT
</B>
and
<B>
UPDATE,
</B>
specify the columns
These column references are converted to
<A
modified by the query.
These column references are converted to
<A
HREF=
"../../include/nodes/primnodes.h"
>
Resdom
</A>
entries, which are
HREF=
"../../include/nodes/primnodes.h"
>
Resdom
</A>
entries, which are
linked together to make up the
<I>
target list
</I>
of the query. The
linked together to make up the
<I>
target list
</I>
of the query. The
target list is stored in Query.targetList, which is generated by
target list is stored in Query.targetList, which is generated by
<A
HREF=
"../../backend/parser/parse_target.c"
>
transformTargetList().
</A>
<A
HREF=
"../../backend/parser/parse_target.c"
>
transformTargetList().
</A>
<P>
<P>
Other query elements, like aggregates(
SUM()), GROUP BY, ORDER BY are
Other query elements, like aggregates(
<B>
SUM()
</B>
),
<B>
GROUP BY,
</B>
also stored in their own Query fields.
<B>
ORDER BY
</B>
are
also stored in their own Query fields.
<P>
<P>
The next step is for the Query to be modified by any
VIEWS or RULES that
The next step is for the Query to be modified by any
<B>
VIEWS
</B>
or
may apply to the query. This is performed by the
<A
<B>
RULES
</B>
that
may apply to the query. This is performed by the
<A
HREF=
"../../backend/rewrite"
>
rewrite
</A>
system.
HREF=
"../../backend/rewrite"
>
rewrite
</A>
system.
<P>
<P>
The
<A
HREF=
"../../backend/optimizer"
>
optimizer
</A>
takes the Query
The
<A
HREF=
"../../backend/optimizer"
>
optimizer
</A>
takes the Query
structure, and generates an optimal
structure and generates an optimal
<A
<A
HREF=
"../..//include/nodes/plannodes.h"
>
Plan
</A>
containing the
HREF=
"../..//include/nodes/plannodes.h"
>
Plan,
</A>
which contains the
primitive operations to be performed by the executor to execute the
operations to be performed to execute the query. The
<A
query. The
<A
HREF=
"../../backend/optimizer/path"
>
path
</A>
module
HREF=
"../../backend/optimizer/path"
>
path
</A>
module determines the best
determines the best table join order and join type of each table in the
table join order and join type of each table in the RangeTable, using
RangeTable, using Query.qual(WHERE clause) to consider optimal index
Query.qual(
<B>
WHERE
</B>
clause) to consider optimal index usage.
usage.
<P>
<P>
The Plan is then passed to the
<A
The Plan is then passed to the
<A
HREF=
"../../backend/executor"
>
executor
</A>
for execution, and the result
HREF=
"../../backend/executor"
>
executor
</A>
for execution, and the result
is
returned to the client.
returned to the client.
<P>
<P>
There are many other modules that support this basic functionality.
There are many other modules that support this basic functionality.
They can be accessed by clicking on the flowchart.
They can be accessed by clicking on the flowchart.
...
@@ -73,39 +72,37 @@ They can be accessed by clicking on the flowchart.
...
@@ -73,39 +72,37 @@ They can be accessed by clicking on the flowchart.
Another area of interest is the shared memory area, containing
Another area of interest is the shared memory area, containing
table data/index blocks, locks, and backend information:
table data/index blocks, locks, and backend information:
<UL>
<UL>
<LI>
ShmemIndex - contains an index of all other shared memory
<LI>
ShmemIndex - lookup of shared memory addresses using structure names
structures, allowing quick lookup of other structure locations in shared
memory
<LI><A
HREF=
"../../include/storage/buf_internals.h"
>
Buffer
<LI><A
HREF=
"../../include/storage/buf_internals.h"
>
Buffer
Descriptors
</A>
- control header for
shared memory buffer
block
Descriptors
</A>
- control header for
buffer cache
block
<LI><A
HREF=
"../../include/storage/buf_internals.h"
>
Buffer Blocks
</A>
-
<LI><A
HREF=
"../../include/storage/buf_internals.h"
>
Buffer Blocks
</A>
data/index buffer cache block
- block of table/index data shared by all backends
<LI>
Shared Buf Lookup Table - lookup of buffer cache block address using
<LI>
Shared Buf Lookup Table - lookup to see if a requested buffer
table name and block number(
<A
HREF=
"../../include/storage/buf_internals.h"
>
is already in the shared memory area
BufferTag
</A>
)
<LI><A
HREF=
"../../include/storage/lock.h"
>
LockTable
</A>
<LI><A
HREF=
"../../include/storage/lock.h"
>
LockTable
(ctl)
</A>
- lock table
- lock table structure, specifiying table, lock types, and
structure, specifiying table, lock types, and backends holding or
backends holding or
waiting on lock
waiting on lock
<LI>
LockTable (lock hash) - lookup of LockTable structures using
<LI>
LockTable (lock hash) - lookup of LockTable structures using
relation
table name
and database object ids
<LI>
LockTable (xid hash) - lookup of LockTable structures using
<LI>
LockTable (xid hash) - lookup of LockTable structures using
transaction id
transaction id
<LI><A
HREF=
"../../include/storage/proc.h"
>
Proc Header
</A>
- information
<LI><A
HREF=
"../../include/storage/proc.h"
>
Proc Header
</A>
- information
about each backend, including locks held/waiting, indexed by process id
about each backend, including locks held/waiting, indexed by process id
</UL>
</UL>
Each data structure is created by calling
<A
Each data structure is created by calling
<A
HREF=
"../../backend/storage/ipc/shmem.c"
>
ShmemInitStruct(),
</A>
and
HREF=
"../../backend/storage/ipc/shmem.c"
>
ShmemInitStruct(),
</A>
and
the lookup
hashe
s are created by
the lookups are created by
<A
HREF=
"../../backend/storage/ipc/shmem.c"
>
ShmemInitHash().
</A>
<A
HREF=
"../../backend/storage/ipc/shmem.c"
>
ShmemInitHash().
</A>
<HR>
<HR>
<CENTER>
<CENTER>
<EM><BIG>
<EM><BIG>
Click on an item to see more detail or
click
Click on an item to see more detail or
<A
HREF=
"backend_dirs.html"
>
here
</a
>
to see the full index.
<A
HREF=
"backend_dirs.html"
>
click
</A
>
to see the full index.
</
EM></BIG
>
</
BIG></EM
>
<BR>
<BR>
<BR>
<BR>
<IMG
src=
"flow.jpg"
usemap=
"#flowmap"
>
<IMG
src=
"flow.jpg"
usemap=
"#flowmap"
alt=
"flowchart"
>
</CENTER>
</CENTER>
<MAP
name=
"flowmap"
>
<MAP
name=
"flowmap"
>
<AREA
COORDS=
"290,10,450,50"
HREF=
"backend_dirs.html#main"
>
<AREA
COORDS=
"290,10,450,50"
HREF=
"backend_dirs.html#main"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment