Re: "Dynamic routing" to different databases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: pgsql-admin-owner@xxxxxxxxxxxxxx [mailto:pgsql-admin-
> owner@xxxxxxxxxxxxxx] On Behalf Of Alex Balashov
> Sent: Thursday, October 01, 2015 10:47 AM
> To: pgsql-admin@xxxxxxxxxxxxxx
> Subject: Re:  "Dynamic routing" to different databases 
> is a psql-level construct, not something that can be embedded in live queries.
> So, I was expecting to have to rewrite thousands of lines of stored procedures
> to take a schema parameter and construct dynamic query strings with dynamic
> table names and so on.
> 
> Assuming one can simply do:
> 
>     SET search_path TO <schema>; SELECT query_business_as_usual();
> 
> I'm in a pretty good place!

You can set the default search path on a per-role/user basis.  What you could do is map a DB user (or set of users) to a specific schema, then set that users search path for the appropriate schema and the queries will automatically get routed to the appropriate schema.  Segmenting your different applications user also allows you to use the role system to restrict access to the data between applications.

The potential downside to this approach is that you won't be able to use something like pgbouncer to share DB connections between the different users/schemas.  This can, depending on your usage and access patterns lead to problems with high connection counts to the DB being needed.

Brad.   

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux