niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » PostgreSQL
New to Schemas - Good for Multi Company in one DB ?
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Paul Newman
*nix forums beginner


Joined: 15 Mar 2005
Posts: 10

PostPosted: Tue Mar 15, 2005 7:14 am    Post subject: New to Schemas - Good for Multi Company in one DB ? Reply with quote

Hi,

I'm a convert from Firebird so I consider myself a newbie to Postgresql.
We have a requirement to host 400 - 600 companies data inside a single
database for connection pooling and scalability reasons as well as our
business logic requirements. We have therefore been very busy adding a
company id to each relevant table and adjusting all our queries to be
company specific ... such that if a company says "show me all my
clients" we would use a query such as Select * from client where comp_id
= 'CompA'



But, I've just discovered Postgresql Schemas ....



If I were to create a schema for each company and therefore remove the
comp_id from our tables and sql would this work ? Could we have 600
schemas in the db ? Would performance be hindered ? If this is OK what
is the best way to maintain all the db structures ? In other words if I
have an update script do I need to run it against each schema ?



I would realy appreciate someones help with this asap .....



Thanks



Paul Newman (Development Director - Tripoint Ltd)
Back to top
Scott Marlowe
*nix forums Guru


Joined: 03 Mar 2005
Posts: 554

PostPosted: Tue Mar 15, 2005 3:44 pm    Post subject: Re: New to Schemas - Good for Multi Company in one DB ? Reply with quote

On Tue, 2005-03-15 at 02:14, Paul Newman wrote:
Quote:
Hi,

I’m a convert from Firebird so I consider myself a newbie to
Postgresql. We have a requirement to host 400 – 600 companies data
inside a single database for connection pooling and scalability
reasons as well as our business logic requirements. We have therefore
been very busy adding a company id to each relevant table and
adjusting all our queries to be company specific … such that if a
company says “show me all my clients” we would use a query such as
Select * from client where comp_id = ‘CompA’



But, I’ve just discovered Postgresql Schemas ….



If I were to create a schema for each company and therefore remove the
comp_id from our tables and sql would this work ? Could we have 600
schemas in the db ? Would performance be hindered ? If this is OK what
is the best way to maintain all the db structures ? In other words if
I have an update script do I need to run it against each schema ?

I just set up a simple test that created 500 or so schemas and the
performance seemed fine to me.

I imagine your system catalogs will be a fair bit bigger than if you had
it all in one table, but the payoff is that when you're looking for the
data for one customer you don't have to go through a huge table of 599
other customers just to get their data. I'm betting multiple schemas
will be a win as long as you aren't needing to union a bunch of schemas
together all the time.

And yes, an update script would have to hit each schema.

If the data between different companies aren't related then schemas
would seem a nice solution to me.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 6:17 am | All times are GMT
navigation Forum index » Databases » PostgreSQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Can any body guide me a for a good tutorial for BIND (DNS) SHERDIL networking 4 Sat Aug 12, 2006 9:40 am
No new posts how to extract multi-line text perltcl@yahoo.com Perl 2 Wed Jul 19, 2006 4:57 am
No new posts Multi master replication question Jeff MySQL 2 Tue Jul 18, 2006 2:22 pm
No new posts Good Representation for an Abstract Syntax Tree johan.tibell@gmail.com C 9 Tue Jul 18, 2006 1:28 pm
No new posts How can I access multi-partition in the USB mass stroage? Leeward hardware 6 Tue Jul 18, 2006 12:43 pm

Debt Consolidation | Facebook Proxy | Car Finance | Debt Consolidation | The eBay Song
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1338s ][ Queries: 16 (0.0652s) ][ GZIP on - Debug on ]