Download pgpool-II user manual

Transcript
Query rewriting
The Query is rewritten by using the execution status acquired while analyzing the query. Here is an example. The
P1-table has the P status, the L1-table has the L status.
SELECT P1-table.col, L1-table.col
FROM P1-table,L1-table
where P1-table.col = L1-table.col
order by P1-table.col;
In this query, because there is an ORDER BY clause, the status is S. The FROM clause, the WHERE clause, and
TARGETLIST are in the P status. The query is rewritten into something like this :
SELECT P1-table.col, L1-table.col FROM
dblink(select pool_parallel(SELECT P1-table.col, L1-table.col FROM P1-table,L1-table where P1-table.col = L1-table.col))
order by P1-table.col;
dblink transmits the query to pgpool-II here. the pool_parallel function is responsible for sending the query to the
parallel execution engine.
In this example, the FROM and WHERE clause, and the TARGETLIST are run in parallel mode. This isn't the real
rewritten query, just something for the sake of providing an example.
Here is another case:
SELECT L1-table.col FROM L1-table WHERE L1-table.col % 2 = 0 AND L1-table.col IN (SELECT P1-table FROM P1-table) ;
In this example, the FROM and WHERE clause and the TARGETLIST are in the L status. Because the subquery is in the
P status, the query itself is in the S status. The rewriting is, as a consequence, performed as follows.
SELECT L1-table.col
FROM dblink(SELECT loadbalance(SELECT L1-table.col
FROM L1-table
WHERE L1-table.col % 2 = 0
AND TRUE))
WHERE
L1-table.col %2 = 0 AND
L1-table.col IN
(
SELECT P1-Table FROM
dblink(select pool_parallel(SELECT P1-table FROM P1-table))
) ;