Re: Number of tables - Mailing list pgsql-performance

From Greg Stark
Subject Re: Number of tables
Date
Msg-id 407d949e0908311801w40889599s3e004588fba70428@mail.gmail.com
Whole thread Raw
In response to Re: Number of tables  (Mike Ivanov <mikei@activestate.com>)
Responses Re: Number of tables
List pgsql-performance
On Tue, Sep 1, 2009 at 1:19 AM, Mike Ivanov<mikei@activestate.com> wrote:
>> i am developing a web app for thousands users (1.000/2.000).
>>
>> Each user have a 2 table of work...I finally have 2.000 (users) x 2 tables
>> = 4.000 tables!
>
> As a someone with a ~50K-table database, I can tell you it's definitely
> possible to survive with such a layout :-)

The usual recommendation is to have a single table (or two tables in
this case) with userid forming part of the primary key in addition to
whatever identifies the records within the user's set of data. You may
not expect to be need to run queries which combine multiple users'
data now but you will eventually.

This doesn't work so great when each user is going to be specifying
their own custom schema on the fly but that's not really what
relational databases were designed for. For that you might want to
look into the hstore contrib module or  something like CouchDB (which
can be combined with Postgres I hear)


--
greg
http://mit.edu/~gsstark/resume.pdf

pgsql-performance by date:

Previous
From: Mike Ivanov
Date:
Subject: Re: Number of tables
Next
From: Mike Ivanov
Date:
Subject: Re: Number of tables