Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2C4879FB1F0 for ; Mon, 4 Jun 2007 15:02:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 39732-09 for ; Mon, 4 Jun 2007 15:02:46 -0300 (ADT) X-Greylist: delayed 00:22:06.439814 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 78DE19FB595 for ; Mon, 4 Jun 2007 15:02:17 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from midas.utopiasystems.net (midas.utopiasystems.net [64.74.150.12]) by svr4.postgresql.org (Postfix) with ESMTP id 955205AF886 for ; Mon, 4 Jun 2007 17:40:09 +0000 (GMT) Received: from 24.62.5.51 ([24.62.5.51]) by midas.utopiasystems.net ([172.16.1.12]) with Microsoft Exchange Server HTTP-DAV ; Mon, 4 Jun 2007 17:40:02 +0000 User-Agent: Microsoft-Entourage/11.3.3.061214 Date: Mon, 04 Jun 2007 13:40:01 -0400 Subject: Thousands of tables versus on table? From: Thomas Andrews To: Message-ID: Thread-Topic: Thousands of tables versus on table? Thread-Index: Acemz2Bznt6lUhLCEdyDLwAX8s2kmQ== Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.636 tagged_above=0 required=5 tests=BAYES_50=0.001, FORGED_RCVD_HELO=0.135, RCVD_NUMERIC_HELO=1.5 X-Spam-Level: * X-Archive-Number: 200706/34 X-Sequence-Number: 25067 I have several thousand clients. Our clients do surveys, and each survey has two tables for the client data, responders responses Frequent inserts into both table. Right now, we are seeing significant time during inserts to these two tables. Some of the indices in tableA and tableB do not index on the client ID first. So, we are considering two possible solutions. (1) Create separate responders and responses tables for each client. (2) Make sure all indices on responders and responses start with the client id (excepting, possibly, the primary keys for these fields) and have all normal operation queries always include an id_client. Right now, for example, given a responder and a survey question, we do a query in responses by the id_responder and id_survey. This gives us a unique record, but I'm wondering if maintaining the index on (id_responder,id_survey) is more costly on inserts than maintaining the index (id_client,id_responder,id_survey) given that we also have other indices on (id_client,...). Option (1) makes me very nervous. I don't like the idea of the same sorts of data being stored in lots of different tables, in part for long-term maintenance reasons. We don't really need cross-client reporting, however. =thomas