Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 66907633958 for ; Sat, 9 Jan 2010 14:50:21 -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 71567-06 for ; Sat, 9 Jan 2010 18:50:11 +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 E06966329CA for ; Sat, 9 Jan 2010 14:50:10 -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 1NTgNz-000EIB-FE; Sat, 09 Jan 2010 21:50:07 +0300 Message-ID: <4B48CFDF.7090406@zhukcity.ru> Date: Sat, 09 Jan 2010 21:50:07 +0300 From: Nickolay User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: =?UTF-8?B?UGllcnJlIEZyw6lkw6lyaWMgQ2FpbGxhdWQ=?= CC: pgsql-performance@postgresql.org Subject: Re: PG optimization question References: <4B485975.70506@zhukcity.ru> <2f4958ff1001090418i78dee992t5ff2d78a54187c07@mail.gmail.com> <4B4879A0.2060703@zhukcity.ru> <20100109124646.GA8123@it.is.rice.edu> <4B487D9C.9020507@zhukcity.ru> In-Reply-To: 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 11580 [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=2.078 tagged_above=-10 required=5 tests=BAYES_05=-1.11, FH_DATE_PAST_20XX=3.188 X-Spam-Level: ** X-Archive-Number: 201001/170 X-Sequence-Number: 37050 Okay, I see your point with staging table. That's a good idea! The only problem I see here is the transfer-to-archive-table process. As you've correctly noticed, the system is kind of a real-time and there can be dozens of processes writing to the staging table, i cannot see how to make the transfer/flush process right and clear... Pierre Frédéric Caillaud wrote: >>>> Oh, btw, 95% of queries are searching rows for current date (last >>>> 24 hours). >>>> >>> >>> You may want to use a daily staging table and then flush to the >>> monthly archive tables at the end of the day. > > If the rows in the archive tables are never updated, this strategy > means you never need to vacuum the big archive tables (and indexes), > which is good. Also you can insert the rows into the archive table in > the order of your choice, the timestamp for example, which makes it > nicely clustered, without needing to ever run CLUSTER. > > And with partitioning you can have lots of indexes on the staging > table (and current months partition) (to speed up your most common > queries which are likely to be more OLTP), while using less indexes on > the older partitions (saves disk space) if queries on old partitions > are likely to be reporting queries which are going to grind through a > large part of the table anyway. > >