PL/Proxy is a language for creating proxy functions that call actual
functions
from a partitioned database. The actual query to be executed on partition is
constructed by looking proxy function signature.
https://developer.skype.com/SkypeGarage/DbProjects/PlProxy
So, to call function "get_user_email(username text) returns text", the proxy
function need to be defined following:
CREATE FUNCTION get_user_email(username text) RETURNS text AS $$
CLUSTER 'userdb';
RUN ON hashtext(username);
$$ LANGUAGE plproxy;
assuming actual partitions are defined under cluster 'userdb' and
users are spread out between partitions by hashtext(name).
PL/Proxy can be used for simple remote queries, without need for any external
configuration:
CREATE FUNCTION get_user_email(username text) RETURNS text AS $$
CONNECT 'dbname=userdb host=1.2.3.4';
SELECT email FROM users WHERE name = username;
$$ LANGUAGE plproxy;
This also demonstrates that its possible to override default 'SELECT *
FROM func(...)'
query generation and to run user-specified SELECT statement on remote server.