Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 78D1863375F for ; Sat, 9 Jan 2010 08:42:24 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 22404-02 for ; Sat, 9 Jan 2010 12:42:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay1.mail.masterhost.ru (relay1.mail.masterhost.ru [83.222.23.61]) by mail.postgresql.org (Postfix) with ESMTP id EE7156329B1 for ; Sat, 9 Jan 2010 08:42:13 -0400 (AST) Received: from [UNAVAILABLE] ([80.252.153.64] helo=[192.168.1.2]) by relay1.mail.masterhost.ru with esmtp envelope from authenticated with postmaster@zhukcity.ru message id 1NTadt-000Cxh-5r; Sat, 09 Jan 2010 15:42:10 +0300 Message-ID: <4B4879A0.2060703@zhukcity.ru> Date: Sat, 09 Jan 2010 15:42:08 +0300 From: Nickolay User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: =?UTF-8?B?R3J6ZWdvcnogSmHFm2tpZXdpY3o=?= CC: pgsql-performance@postgresql.org Subject: Re: PG optimization question References: <4B485975.70506@zhukcity.ru> <2f4958ff1001090418i78dee992t5ff2d78a54187c07@mail.gmail.com> In-Reply-To: <2f4958ff1001090418i78dee992t5ff2d78a54187c07@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SpamTest-Envelope-From: nitro@zhukcity.ru X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 11577 [Jan 09 2010] X-SpamTest-Info: {relay has no DNS name} X-SpamTest-Method: none X-SpamTest-Rate: 40 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0284], KAS30/Release X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.589 tagged_above=-10 required=5 tests=BAYES_00=-2.599, FH_DATE_PAST_20XX=3.188 X-Spam-Level: X-Archive-Number: 201001/161 X-Sequence-Number: 37041 I do not see any way to normalize this table anymore. it's size is 4Gig for ~4M rows, i.e. 1Kb per row, i think it's ok. Also there are 2 indexes: by date_time and by a couple of service fields (total index size is 250Mb now). I think i'll be going to partition by months (approx. 1M rows or 1Gig per month), so it would be like 60 partitions for 5 years. Is that OK for postgres? Oh, btw, 95% of queries are searching rows for current date (last 24 hours). Also we use SELECT...FOR UPDATE row-level locking for updating the rows in archive (i.e. we INSERT new row when starting outgoing message transmittion and then doing SELECT...FOR UPDATE and UPDATE for source (incoming) message when outgoing message was sent), so I guess we would have to explicitly write the name of partition table (i.e. "archive_2009_12" instead of "archive") for SELECT...FOR UPDATE and UPDATE requests, as they may need to access row in previous partition instead of the current one. Grzegorz Jaƛkiewicz wrote: > maybe that 'one big table' needs something called 'normalisation' > first. See how much that will shed off. You might be surprised. > The partitioning needs to be done by some constant intervals, of time > - in your case. Whatever suits you, I would suggest to use the rate > that will give you both ease of archiving/removal of old data (so not > too wide), and also, one that would make sure that most of the data > you'll be searching for in your queries will be in one , two > partitions per query. > > >