Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 38FCBB5DBC4 for ; Thu, 20 Oct 2011 00:44:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 25517-02 for ; Thu, 20 Oct 2011 03:44:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by mail.postgresql.org (Postfix) with ESMTP id 9F043B5DBC0 for ; Thu, 20 Oct 2011 00:44:44 -0300 (ADT) Received: by qabj40 with SMTP id j40so1842095qab.19 for ; Wed, 19 Oct 2011 20:44:44 -0700 (PDT) Received: by 10.229.67.95 with SMTP id q31mr1991583qci.170.1319082284080; Wed, 19 Oct 2011 20:44:44 -0700 (PDT) Received: from ayaki.localdomain (124-169-43-32.dyn.iinet.net.au. [124.169.43.32]) by mx.google.com with ESMTPS id em7sm2250944qab.6.2011.10.19.20.44.39 (version=SSLv3 cipher=OTHER); Wed, 19 Oct 2011 20:44:43 -0700 (PDT) Message-ID: <4E9F9924.7020707@ringerc.id.au> Date: Thu, 20 Oct 2011 11:44:36 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: kzsolt CC: pgsql-performance@postgresql.org Subject: Re: Heavy contgnous load References: <1318939765661-4913425.post@n5.nabble.com> <4E9E204B.2040608@ringerc.id.au> <1319050535000-4919006.post@n5.nabble.com> In-Reply-To: <1319050535000-4919006.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/174 X-Sequence-Number: 45396 On 10/20/2011 02:55 AM, kzsolt wrote: > "try to have as few indexes as possible and do your inserts inside > transactions in batches, rather than one-by-one as individual statements. " > That is the main problem. I use now few index as possible. Unfortunately the > one-by-one INSERT is nature of or system. To join (batch) inserts is require > spacial cache with inactivity timeout. But this timout are make more trouble > for our application. The flat file has same problem. Well, then you'll have to use an unlogged table (9.1 or newer only) to insert into, then periodically copy rows from the unlogged table into the main table using something like PgAgent to schedule the copy. An unlogged table is a tiny bit more like MySQL's MyISAM tables in that it doesn't have any crash recovery features. It still supports transactions, of course, and you won't find any way to remove transaction support in PostgreSQL. One of the reasons MySQL has historically had so many bizarre behaviours, like (by default) writing invalid data as NULL, inserting zeroes for invalid dates, etc is because MyISAM can't roll back transactions when it discovers a problem partway through, so it has to finish the job badly rather than error out and leave the job half-completed. If you really need absolutely maximum insert performance, you should just use a flat file or a different database system. Relational databases like PostgreSQL are designed for reliable concurrency, crash safety, fast querying, and data integrity, and they provide those at the cost of slower data insertion among other things. -- Craig Ringer