Re: why use SCHEMA? any real-world examples? - Mailing list pgsql-general

From Gregory S. Williamson
Subject Re: why use SCHEMA? any real-world examples?
Date
Msg-id 71E37EF6B7DCC1499CEA0316A256832801D4BB75@loki.wc.globexplorer.net
Whole thread Raw
In response to why use SCHEMA? any real-world examples?  ("Net Virtual Mailing Lists" <mailinglists@net-virtual.com>)
List pgsql-general
As other posters have indicated, there's a convenience factor and an advantage to compartmentalizing data. In our case
wedon't care so much about user rights (a very useful aspect in and of itself), but more for performance issues. 

We have some applications that use a lot of detailed data about properties in different counties. We have a central
tablethat stores their spatial attributes and some data about the properties themselves. The table has several million
rowscurrently -- selections based on a bounding box are very fast, but if we try to get a list of all properties on all
streetswith names like "Elm%" in a given county, the select is painfully slow as the index (county / street in this
simplifiedcase) lacks specificity -- any given county yields say a half million rows as candidates by county, with
hundredsof possible street entries, so sequential scans are used. 

Hence, I broke out some of the property data that needed to be searched by county, with each county in its own
schema,andeach schema has the same tables (so the schema called "f10675" has a "name_search" table that has the same
nameas the "f01223" schema, but its own contents. 

The search tables all refer to the original data by a unique identifier that is common between the schema/search tables
andthe main store. The search in these schema based tables is much faster because the specificity of the index is much
greater,yielding only dozens or hundreds of candidates out of hundreds of thousands of rows.  

The extra space taken by redundant data storage is more than compensated for by speed in retrieval.

HTH clarify possibilties,

Greg WIlliamson
DBA
GlobeXplorer LLC

-----Original Message-----
From:    Miles Keaton [mailto:mileskeaton@gmail.com]
Sent:    Wed 11/24/2004 9:12 PM
To:    pgsql-general@postgresql.org
Cc:
Subject:    [GENERAL] why use SCHEMA? any real-world examples?
I just noticed PostgreSQL's schemas for my first time.
(http://www.postgresql.org/docs/current/static/ddl-schemas.html)

I Googled around, but couldn't find any articles describing WHY or
WHEN to use schemas in database design.

Since the manual says HOW, could anyone here who has used schemas take
a minute to describe to a newbie like me why you did?   What benefits
did they offer you?   Any drawbacks?

Thanks for your time.

- Miles

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend




pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: [HACKERS] Help!
Next
From: Nageshwar Rao
Date:
Subject: How to display structure of a table