]> begriffs open source - ai-pg/blob - full-docs/html/connect-estab.html
Include latest toc output
[ai-pg] / full-docs / html / connect-estab.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>51.2. How Connections Are Established</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="query-path.html" title="51.1. The Path of a Query" /><link rel="next" href="parser-stage.html" title="51.3. The Parser Stage" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">51.2. How Connections Are Established</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="query-path.html" title="51.1. The Path of a Query">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="overview.html" title="Chapter 51. Overview of PostgreSQL Internals">Up</a></td><th width="60%" align="center">Chapter 51. Overview of PostgreSQL Internals</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="parser-stage.html" title="51.3. The Parser Stage">Next</a></td></tr></table><hr /></div><div class="sect1" id="CONNECT-ESTAB"><div class="titlepage"><div><div><h2 class="title" style="clear: both">51.2. How Connections Are Established <a href="#CONNECT-ESTAB" class="id_link">#</a></h2></div></div></div><p>
3     <span class="productname">PostgreSQL</span> implements a
4     <span class="quote">“<span class="quote">process per user</span>”</span> client/server model.
5     In this model, every
6     <a class="glossterm" href="glossary.html#GLOSSARY-CLIENT"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-CLIENT" title="Client (process)">client process</a></em></a>
7     connects to exactly one
8     <a class="glossterm" href="glossary.html#GLOSSARY-BACKEND"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-BACKEND" title="Backend (process)">backend process</a></em></a>.
9     As we do not know ahead of time how many connections will be made,
10     we have to use a <span class="quote">“<span class="quote">supervisor process</span>”</span> that spawns a new
11     backend process every time a connection is requested. This supervisor
12     process is called
13     <a class="glossterm" href="glossary.html#GLOSSARY-POSTMASTER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-POSTMASTER" title="Postmaster (process)">postmaster</a></em></a>
14     and listens at a specified TCP/IP port for incoming connections.
15     Whenever it detects a request for a connection, it spawns a new
16     backend process.  Those backend processes communicate with each
17     other and with other processes of the
18     <a class="glossterm" href="glossary.html#GLOSSARY-INSTANCE"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-INSTANCE" title="Instance">instance</a></em></a>
19     using <em class="firstterm">semaphores</em> and
20     <a class="glossterm" href="glossary.html#GLOSSARY-SHARED-MEMORY"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-SHARED-MEMORY" title="Shared memory">shared memory</a></em></a>
21     to ensure data integrity throughout concurrent data access.
22    </p><p>
23     The client process can be any program that understands the
24     <span class="productname">PostgreSQL</span> protocol described in
25     <a class="xref" href="protocol.html" title="Chapter 54. Frontend/Backend Protocol">Chapter 54</a>.  Many clients are based on the
26     C-language library <span class="application">libpq</span>, but several independent
27     implementations of the protocol exist, such as the Java
28     <span class="application">JDBC</span> driver.
29    </p><p>
30     Once a connection is established, the client process can send a query
31     to the backend process it's connected to. The query is transmitted using
32     plain text, i.e., there is no parsing done in the client. The backend
33     process parses the query, creates an <em class="firstterm">execution plan</em>,
34     executes the plan, and returns the retrieved rows to the client
35     by transmitting them over the established connection.
36    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="query-path.html" title="51.1. The Path of a Query">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="overview.html" title="Chapter 51. Overview of PostgreSQL Internals">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="parser-stage.html" title="51.3. The Parser Stage">Next</a></td></tr><tr><td width="40%" align="left" valign="top">51.1. The Path of a Query </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 51.3. The Parser Stage</td></tr></table></div></body></html>