X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1D5DE475B47 for ; Mon, 21 Apr 2003 05:10:41 -0400 (EDT) Received: from menkalinam.com (menkalinam.com [216.121.191.210]) by postgresql.org (Postfix) with ESMTP id 1E95A475A80 for ; Mon, 21 Apr 2003 05:10:40 -0400 (EDT) Received: from cris (docs51-33.menta.net [62.57.50.33]) by menkalinam.com Dinamail Server with SMTPœ id h3L9AMk23754; Mon, 21 Apr 2003 02:10:28 -0700 Message-ID: <016d01c307e5$d85acb40$2132393e@cris> From: "Cristina Surroca" To: "kp" , References: <3EA231D2.2040305@pobox.gr> Subject: Re: Sequence scans on indexed row Date: Mon, 21 Apr 2003 11:10:16 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Status: No, hits=-19.1 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/285 X-Sequence-Number: 8440 Hello, I had the same problem days ago. My fault was that I didn't use 'XXX' on update. I mean: Update Table set column = XXX where indexcoulm='something'; Perhaps it is something like this... good luck yours Cris.. ----- Original Message ----- From: "kp" To: Sent: Sunday, April 20, 2003 7:36 AM Subject: [ADMIN] Sequence scans on indexed row > Hello all. > > I am doing a straight forward update on a table with over 1.6 million > records based on a where clause that only uses one of its indexed > columns (btree on a varchar). However postgres instists on not using the > index and instead does a sequence scan that takes ages to complete. > > The weird thing is that the same table has another column indexed in > exactly the same way (btree on a varchar) which postgres correctly uses > the index on. > > One difference between the two columns is that on one I have fixed the > maximum size of the varchar to 80 while the other is free to grow as > much as it wants. > > The other difference between these two columns (or rather the kind of > data they contain) is that the column for which postgres *uses* the > index on contains around 32000 distinct values while the other only > contains 14 distinct values. > > I have a suspicion that postgres (i'm using 7.1.3) incorrectly assumes > that a sequence scan is cheaper for the column with the 14 distinct > values in it and ends up scanning 1.6 million rows. > > Bug? If so, has it been fixed on later versions? > > TIA for any replies, > kp > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly