Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2C7EDEC7B26 for ; Fri, 6 Jul 2012 11:22:44 -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 1Sn9Qf-0003w6-Hw for pgsql-performance@postgresql.org; Fri, 06 Jul 2012 14:22:43 +0000 Received: by pbbrp8 with SMTP id rp8so14692905pbb.19 for ; Fri, 06 Jul 2012 07:22:27 -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:content-transfer-encoding :x-gm-message-state; bh=Pb3uFKo983Lla7B7ihVetMJLxqbfzGhl6u9oAJJHLas=; b=Jbe+Pfz89czOH7jEOq78vdxlMvnvsCJ3H0252ZBBLZ5bLTTiDvcFe4NyTUUwgVMgqm 3b9qLgMczGd/KTSiYdU2oar47GNIXmz7c6GSwOl595KENqVB9bOXIjpVHrMTzSGTvePU /RAXJFQ0l4GHn2RX9PcvCaqZYTc3OkglssfCdrhX7fAZDoFJ7MkClFhP8xydSTtazdc0 pSwvb8CEx4q8NXyGOFVaAy58xTi+O4EBJLiBj3OhBXiSJm+IgAshHCjJE942YCtB916K gUFQTxJtfWONjfLZBtMwLrxmTdLLsWwOVlVDqSalQZG84WOXKuVrF+O8wqmiU1JezdlG s41Q== Received: by 10.68.193.195 with SMTP id hq3mr37363052pbc.30.1341584547087; Fri, 06 Jul 2012 07:22:27 -0700 (PDT) Received: from ayaki.localdomain (124-169-169-118.dyn.iinet.net.au. [124.169.169.118]) by mx.google.com with ESMTPS id qi8sm21966846pbc.36.2012.07.06.07.22.24 (version=SSLv3 cipher=OTHER); Fri, 06 Jul 2012 07:22:26 -0700 (PDT) Message-ID: <4FF6F49D.7050507@ringerc.id.au> Date: Fri, 06 Jul 2012 22:22:21 +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: Daniel Farina , 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: <4FF6CC11.2000904@ringerc.id.au> <4FF6EA64.9010308@ringerc.id.au> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnU1yc1jqXfBknOuO6LYfZJIjxJO5b04+MScRMcnLNkfHMf+145uX4x5qYypNPMwKlAjW+A X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/64 X-Sequence-Number: 47245 On 07/06/2012 09:45 PM, Stanislaw Pankevich wrote: > Question: Is there a possibility in PostgreSQL to do DELETE on many > tables massively, like TRUNCATE allows. Like DELETE table1, table2, ...? Yes, you can do it with a writable common table expression, but you wanted version portability. WITH discard1 AS (DELETE FROM test1), discard2 AS (DELETE FROM test2 AS b) SELECT 1; Not only will this not work in older versions (IIRC it only works with 9.1, maybe 9.0 too but I don't see it in the documentation for SELECT for 9.0) but I find it hard to imagine any performance benefit over simply sending DELETE FROM test1; DELETE FROM test2; This all smells like premature optimisation of cases that don't matter. What problem are you solving with this? -- Craig Ringer