X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A0308BA0E0 for ; Mon, 14 Feb 2005 12:48:01 +0000 (GMT) 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 87980-03 for ; Mon, 14 Feb 2005 12:47:57 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) by svr1.postgresql.org (Postfix) with ESMTP id 08A9F8B9EAD for ; Mon, 14 Feb 2005 12:47:56 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 2229631E04; Mon, 14 Feb 2005 13:47:57 +0100 (MET) From: Christopher Browne X-Newsgroups: pgsql.performance Subject: Re: estimated rows vs. actual rows Date: Mon, 14 Feb 2005 07:41:13 -0500 Organization: cbbrowne Computing Inc Lines: 30 Message-ID: References: <200502131341.09811.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Corporate Culture, linux) Cancel-Lock: sha1:B7qCLE39aCv5fUg07Bz+WBHwohk= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.091 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/210 X-Sequence-Number: 10539 After takin a swig o' Arrakan spice grog, systemguards@gmail.com (Jaime Casanova) belched out: > On Sun, 13 Feb 2005 13:41:09 -0800, Josh Berkus wrote: >> Jaime, >> >> > Why is this query using a seq scan rather than a index scan? >> >> Because it thinks a seq scan will be faster. >> > I will suggest him to probe with seq scans disabled. > > But, IMHO, if the table has 143902 and it thinks will retrieve 2610 > (almost 1.81% of the total). it won't be faster with an index? If the 2610 rows are scattered widely enough, it may be cheaper to do a seq scan. After all, with a seq scan, you read each block of the table's pages exactly once. With an index scan, you read index pages _and_ table pages, and may do and redo some of the pages. It sounds as though it's worth forcing the matter and trying it both ways and comparing them. Don't be surprised if the seq scan is in fact faster... -- select 'cbbrowne' || '@' || 'gmail.com'; http://cbbrowne.com/info/emacs.html When aiming for the common denominator, be prepared for the occasional division by zero.