Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TO2DU-0001ck-Eu for pgsql-performance@postgresql.org; Tue, 16 Oct 2012 08:09:32 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TO2DP-0002bC-7c for pgsql-performance@postgresql.org; Tue, 16 Oct 2012 08:09:32 +0000 Received: by mail-pa0-f46.google.com with SMTP id hz1so5675808pad.19 for ; Tue, 16 Oct 2012 01:09:26 -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=SNwDWYrGj+VxJ2kUDA1aNErwtB1YRvUp6Kw8R+TzI/Y=; b=XrAYRjp9qnux024YOuQ2v/2CE2aO4SuQn1gpdqBirjIe4Hy2mWl93szDOHXg76Jxgg x5udpgpl78QUF8cJpDXCtrxp4FB9j2kjUAP5XhFTF4bp+lClkUSc4QClxZfspQ8PMAfX a15YewkInMLuLORUdbLcvmjzLPQDVCeXtQmHS16AviW8aQOky0mGKzaUnGxiX+SzSKTC RKaltERALHyHBW7tu1OrO1ctrW/5Q9/ajhjHHGht1qo6UgbuaP0SJ+iLrCt+J18ZBoWD mI1boBoT1t3KpKQAixjrQcHFHIF/S45FXcuOCoVDzODpSr9Cjk2oFWn2d/W8IAYPVRLl wCUA== Received: by 10.68.234.36 with SMTP id ub4mr44824703pbc.68.1350374966051; Tue, 16 Oct 2012 01:09:26 -0700 (PDT) Received: from ayaki.localdomain (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id nm2sm2187568pbc.43.2012.10.16.01.09.23 (version=SSLv3 cipher=OTHER); Tue, 16 Oct 2012 01:09:25 -0700 (PDT) Message-ID: <507D1631.9050904@ringerc.id.au> Date: Tue, 16 Oct 2012 16:09:21 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Sylvain CAILLET CC: pgsql-performance@postgresql.org Subject: Re: Slow Delete : Seq scan instead of index scan References: <1837771448.3789694.1350373812378.JavaMail.root@alaloop.com> In-Reply-To: <1837771448.3789694.1350373812378.JavaMail.root@alaloop.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnoQKm9WatnTC4P+0u9u1DEKGkCnIxKvqrSncKqI5CdaK/BJD5x+YLGfAvqxyo3TAlordxn X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/203 X-Sequence-Number: 48162 On 10/16/2012 03:50 PM, Sylvain CAILLET wrote: > Hi to all, > > I've got a trouble with some delete statements. My db contains a little > more than 10000 tables and runs on a dedicated server (Debian 6 - bi > quad - 16Gb - SAS disks raid 0). Most of the tables contains between 2 > and 3 million rows and no foreign keys exist between them. Each is > indexed (btree) on start_date / end_date fields (bigint). The Postgresql > server has been tuned (I can give modified values if needed). > > I perform recurrent DELETE upon a table subset (~1900 tables) and each > time, I delete a few lines (between 0 and 1200). Usually it takes > between 10s and more than 2mn. It seems to me to be a huge amount of > time ! An EXPLAIN ANALYZE on a DELETE shows me that the planner uses a > Seq Scan instead of an Index Scan. Can you post that (or paste to explain.depesz.com and link to it here) along with a "\d tablename" from psql? -- Craig Ringer