ruby on rails - Can 20,000 schemas exist in a single Postgres database? -


can single postgres database contain more 20,000 schemas? implications of such database design.

i reading postgres schemas here - http://www.postgresql.org/docs/8.2/static/ddl-schemas.html , i'm planning create 1 schema per account in multi-tenant ruby on rails app. each schema have set of tables store data of relevant account.

each user/schema features offer, have 50-60 tables.

can postgres handle of without hiccups, provided allocate large ec2 instance host database server ?

[update]

by experience if 1 faced trouble such number of schemas in postgres, share , thought can more guidance avoid such pitfalls.

you can create 20,000 schemas in single postgresql database, that's not it's idea.

firstly, design point of view if want add new column table, that's 20,000 tables update. - if want view totals users, that's 20,000 table union you're going have write - not pretty.

secondly, there have historically been issues large numbers of schemas , tables. not point of view of individual queries querying system catalogues. of system views , functions have had simplistic implementation works fine 100 tables painfully slow 10,000. that's not bad thing - why complicate core functionality 99% of users when you've got works?

there have been minor tweaks made here , there in system catalogues push limits people attempting sort of design. limits depend upon usage pattern though. it's been while since looked @ activerecord or of kin, in development mode used query catalogues time check table definitions - painful. in production though, might not have problem after slow startup.

i don't see ec2 stuff matters here - long have cpu , ram requirements.

so - in summary:

  • it can done
  • odd corners show o(n2) rather o(n log n) performance 20,000 schemas noticable.

check postgresql.org mailing list archives previous discussion of - that's place go if want detailed information.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -