Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 3F5CDABB2F9 for ; Sat, 14 Jul 2012 00:35:54 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Spt91-0003Rf-6X for pgsql-performance@postgresql.org; Sat, 14 Jul 2012 03:35:53 +0000 Received: by pbbrp8 with SMTP id rp8so6495616pbb.19 for ; Fri, 13 Jul 2012 20:35:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=2u3AyVQZ9izttqixTw/e4o2M+HMGDHfuA9egkVv+Uxs=; b=igKe951f7lFxkMAo4iHj2FqH2j+u/SJjuYlkiPStbAzk37sBL8jfQhzoUR6SDgb3xx 1vyjMteuO3QsSKYYsU1ooLbESZWa7BSRrqkbc05tYxjtfQbrurQ4onQy3j6lcDyz1LOk xJUGmvgt4AFIM7PMhZn0Y7UKebHmBNvG/SChcKQ0aSuJSeE03xTVdzyPVomoLcllK5rS zTacsKgRV3ir+fPAM7eJwZgEPy2v6IgSkkHNagsEfRDNm4kqIRCj52IQgMtSEymINRn/ pHOtO/N+T4rfPK3dbRJEPal6RGZwIqmU0IaSyum4iruRTDkaU0RRy6xlQlOAPEYzWHCD ic8g== Received: by 10.68.193.195 with SMTP id hq3mr8602517pbc.30.1342236932992; Fri, 13 Jul 2012 20:35:32 -0700 (PDT) Received: from ayaki.localdomain (58-7-231-93.dyn.iinet.net.au. [58.7.231.93]) by mx.google.com with ESMTPS id nv10sm7227153pbb.49.2012.07.13.20.35.30 (version=SSLv3 cipher=OTHER); Fri, 13 Jul 2012 20:35:31 -0700 (PDT) Message-ID: <5000E8FF.3080309@ringerc.id.au> Date: Sat, 14 Jul 2012 11:35:27 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Stanislaw Pankevich CC: pgsql-performance@postgresql.org Subject: Re: PostgreSQL db, 30 tables with number of rows < 100 (not huge) - the fastest way to clean each non-empty table and reset unique identifier column of empty ones. References: <4FF70D17.3070309@pinpointresearch.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------070903080604090201060702" X-Gm-Message-State: ALoCoQll3ZnmoVWT/fOZWc2YoXQghxYJ6OgY9NimaOEbemmfPOyjckLM7fj5JrWxCHdC3GeS61X2 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201207/182 X-Sequence-Number: 47363 This is a multi-part message in MIME format. --------------070903080604090201060702 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07/13/2012 03:50 PM, Stanislaw Pankevich wrote: > MySQL: the fastest strategy for cleaning databases is truncation with > following modifications: > 1) We check is table is not empty and then truncate. > 2) If table is empty, we check if AUTO_INCREMENT was changed. If it > was, we do a truncate. > > For MySQL just truncation is much faster than just deletion. You're talking about MySQL like it's only one database. Is this with MyISAM tables? InnoDB? Something else? I don't see any mention of table formats in a very quick skim of the discussion you linked to. PostgreSQL will /never/ be able to compete with MyISAM on raw speed of small, simple operations. There might things that can be made faster than they are right now, but I really doubt it'll ever surpass MyISAM. My mental analogy is asking an abseiler, who is busy clipping in and testing their gear at the top of a bridge, why they aren't at the bottom of the canyon with the BASE jumper yet. The BASE jumper will always get there faster, but the abseiler will always get there alive. If you're talking about InnoDB or another durable, reliable table structure then I'd be interested in the mechanics of what MySQL's truncates are doing. -- Craig Ringer --------------070903080604090201060702 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 07/13/2012 03:50 PM, Stanislaw Pankevich wrote:
MySQL: the fastest strategy for cleaning databases is truncation with
following modifications:
1) We check is table is not empty and then truncate.
2) If table is empty, we check if AUTO_INCREMENT was changed. If it
was, we do a truncate.

For MySQL just truncation is much faster than just deletion. 
You're talking about MySQL like it's only one database. Is this with MyISAM tables? InnoDB? Something else? I don't see any mention of table formats in a very quick skim of the discussion you linked to.

PostgreSQL will never be able to compete with MyISAM on raw speed of small, simple operations. There might things that can be made faster than they are right now, but I really doubt it'll ever surpass MyISAM.

My mental analogy is asking an abseiler, who is busy clipping in and testing their gear at the top of a bridge, why they aren't at the bottom of the canyon with the BASE jumper yet.

The BASE jumper will always get there faster, but the abseiler will always get there alive.

If you're talking about InnoDB or another durable, reliable table structure then I'd be interested in the mechanics of what MySQL's truncates are doing.

--
Craig Ringer
--------------070903080604090201060702--