Current File : //usr/share/doc/postgresql-9.2.24/html/connect-estab.html |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>How Connections are Established</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.2.24 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Overview of PostgreSQL Internals"
HREF="overview.html"><LINK
REL="PREVIOUS"
TITLE="The Path of a Query"
HREF="query-path.html"><LINK
REL="NEXT"
TITLE="The Parser Stage"
HREF="parser-stage.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2017-11-06T22:43:11"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.2.24 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="The Path of a Query"
HREF="query-path.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="overview.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 44. Overview of PostgreSQL Internals</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="The Parser Stage"
HREF="parser-stage.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CONNECT-ESTAB"
>44.2. How Connections are Established</A
></H1
><P
> <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> is implemented using a
simple <SPAN
CLASS="QUOTE"
>"process per user"</SPAN
> client/server model. In this model
there is one <I
CLASS="FIRSTTERM"
>client process</I
> connected to
exactly one <I
CLASS="FIRSTTERM"
>server process</I
>. As we do not
know ahead of time how many connections will be made, we have to
use a <I
CLASS="FIRSTTERM"
>master process</I
> that spawns a new
server process every time a connection is requested. This master
process is called <TT
CLASS="LITERAL"
>postgres</TT
> and listens at a
specified TCP/IP port for incoming connections. Whenever a request
for a connection is detected the <TT
CLASS="LITERAL"
>postgres</TT
>
process spawns a new server process. The server tasks
communicate with each other using <I
CLASS="FIRSTTERM"
>semaphores</I
> and
<I
CLASS="FIRSTTERM"
>shared memory</I
> to ensure data integrity
throughout concurrent data access.
</P
><P
> The client process can be any program that understands the
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> protocol described in
<A
HREF="protocol.html"
>Chapter 46</A
>. Many clients are based on the
C-language library <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>, but several independent
implementations of the protocol exist, such as the Java
<SPAN
CLASS="APPLICATION"
>JDBC</SPAN
> driver.
</P
><P
> Once a connection is established the client process can send a query
to the <I
CLASS="FIRSTTERM"
>backend</I
> (server). The query is transmitted using plain text,
i.e., there is no parsing done in the <I
CLASS="FIRSTTERM"
>frontend</I
> (client). The
server parses the query, creates an <I
CLASS="FIRSTTERM"
>execution plan</I
>,
executes the plan and returns the retrieved rows to the client
by transmitting them over the established connection.
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="query-path.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="parser-stage.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The Path of a Query</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="overview.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The Parser Stage</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>