X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0ECE8D7B37 for ; Fri, 2 Sep 2005 13:47:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12319-01 for ; Fri, 2 Sep 2005 16:47:29 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 37A59D7A95 for ; Fri, 2 Sep 2005 13:47:26 -0300 (ADT) Received: (qmail 28381 invoked from network); 2 Sep 2005 18:47:54 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 2 Sep 2005 18:47:54 +0200 To: arnaulist@andromeiberica.com, pgsql-performance@postgresql.org Subject: Re: Advise about how to delete entries References: <43183AC9.1060704@andromeiberica.com> Message-ID: Date: Fri, 02 Sep 2005 18:47:21 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <43183AC9.1060704@andromeiberica.com> User-Agent: Opera M2/8.0 (Linux, build 1095) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/58 X-Sequence-Number: 14366 > "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" As Michael said, why use a NUMERIC when a bigint is faster and better for your use case, as you only need an integer and not a fixed precision decimal ? Also if you use postgres < 8, the index will not be used if you search on a type different from the column type. So, if your key is a bigint, you should do WHERE statistic_id = 9832::bigint. For mass deletes like this, you should use one of the following, which will be faster : DELETE FROM ... WHERE ID IN (list of values) Don't put the 30000 values in the same query, but rather do 300 queries with 100 values in each. COPY FROM a file with all the ID's to delete, into a temporary table, and do a joined delete to your main table (thus, only one query). EXPLAIN DELETE is your friend.