Database Reference
In-Depth Information
2. Then, install the language in the database as an extension, which will be
hosting the PL/Proxy functions:
-bash-4.2$ psql -c "CREATE EXTENSION
plproxy" proxy1
CREATE EXTENSION
Tip
At the time of writing this topic, the PL/Proxy language is still not completely
integrated with the PostgreSQL standard distribution. The SQL commands
CREATE LANGUAGE plproxy
and its command-line equivalent
createlang
plproxy
do not work. This may have been fixed by the time you read this, so
you can try these first.
PL/Proxy language syntax
The PL/Proxy language itself is very simple. The purpose of a PL/Proxy function is
to hand off the processing to another server so that it only needs six statements:
•
CONNECT
or
CLUSTER
and
RUN ON
for selecting the target database par-
tition
•
SELECT
and
TARGET
for specifying the query to run
•
SPLIT
for splitting an
ARRAY
argument between several sub-arrays for
running on multiple partitions
CONNECT, CLUSTER, and RUN ON
The first group of statements handle the remote connectivity to the partitions. The
help determines which database to run the query on. You specify the exact partition
to run the query using
CONNECT
:
CONNECT 'connect string' ;