Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 660CD9FB45F for ; Tue, 5 Jun 2007 15:55:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 77536-08 for ; Tue, 5 Jun 2007 15:55:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from oxford.xeocode.com (unknown [87.127.95.194]) by postgresql.org (Postfix) with ESMTP id 442039FB356 for ; Tue, 5 Jun 2007 15:55:50 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1HveC0-0001Cp-Sa; Tue, 05 Jun 2007 19:55:44 +0100 From: Gregory Stark To: "Scott Marlowe" Cc: , "Thomas Andrews" , "Mark Lewis" , Subject: Re: Thousands of tables versus on table? In-Reply-To: <466593E5.1010904@g2switchworks.com> (Scott Marlowe's message of "Tue, 05 Jun 2007 11:48:37 -0500") Organization: EnterpriseDB References: <1180980943.31471.322.camel@archimedes> <46645DD9.7030805@soliantconsulting.com> <877iqjmro5.fsf@oxford.xeocode.com> <46647427.4030103@g2switchworks.com> <466593E5.1010904@g2switchworks.com> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX" 20204) Date: Tue, 05 Jun 2007 19:55:44 +0100 Message-ID: <87sl96z0wf.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/75 X-Sequence-Number: 25108 "Scott Marlowe" writes: > Sorry, I think I initially read your response as "Postgres doesn't really get > any faster by breaking the tables up" without the "like that" part. Well breaking up the tables like that or partitioning, either way should be about equivalent really. Breaking up the tables and doing it in the application should perform even better but it does make the schema less flexible and harder to do non-partition based queries and so on. I guess I should explain what I originally meant: A lot of people come from a flat-file world and assume that things get slower when you deal with large tables. In fact due to the magic of log(n) accessing records from a large index is faster than first looking up the table and index info in a small index and then doing a second lookup in up in an index for a table half the size. Where the win in partitioning comes in is in being able to disappear some of the data entirely. By making part of the index key implicit in the choice of partition you get away with a key that's half as large. And in some cases you can get away with using a different key entirely which wouldn't otherwise have been feasible to index. In some cases you can even do sequential scans whereas in an unpartitioned table you would have to use an index (or scan the entire table). But the real reason people partition data is really for the management ease. Being able to drop, and load entire partitions in O(1) is makes it feasible to manage data on a scale that would simply be impossible without partitioned tables. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com