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 4FFDF329E5D for ; Sat, 11 Sep 2004 07:07:56 +0100 (BST) 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 03361-08 for ; Sat, 11 Sep 2004 06:07:50 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 9199C329E5A for ; Sat, 11 Sep 2004 07:07:49 +0100 (BST) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 1C6134-000PKW-0X; Sat, 11 Sep 2004 06:07:46 +0000 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.34) id 1C6130-0008H8-Bg; Sat, 11 Sep 2004 07:07:42 +0100 Subject: Re: Stuck using Sequential Scan From: Oliver Elphick Reply-To: olly@lfix.co.uk To: jeremy.guthrie@berbee.com Cc: pgsql-performance@postgresql.org In-Reply-To: <200409071632.05374.jeremy.guthrie@berbee.com> References: <200409071632.05374.jeremy.guthrie@berbee.com> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1094882862.14510.982.camel@linda> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sat, 11 Sep 2004 07:07:42 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/72 X-Sequence-Number: 8200 On Tue, 2004-09-07 at 22:32, Jeremy M. Guthrie wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I have a problem where I have the table format listed below. I have the > primary key tsyslog_id and the index built against it. However, when I > select a unique row, it will only ever do a seq scan even after I turn off > all other types except indexscan. I understand you cannot fully turn off seq > scan. ... > I cannot run vacuum more than once a day because of its heavy IO penalty. I > run analyze once an hour. However, if I run analyze then explain, I see no > difference in the planners decisions. What am I missing? > > > TSyslog=# \d syslog_tarchive; > Table "public.syslog_tarchive" > Column | Type | > Modifiers > - ------------+------------------------+------------------------------------------------------------------------- > tsyslog_id | bigint | not null default ... > > TSyslog=# explain select * from tsyslog where tsyslog_id=431650835; That constant is INTEGER, whereas the column is BIGINT; there is no automatic conversion in this case, so the planner does not realise the index is usable for this query (I think 8.0 solves this). Try: select * from tsyslog where tsyslog_id=431650835::BIGINT; -- Oliver Elphick olly@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA ======================================== "I am crucified with Christ; nevertheless I live; yet not I, but Christ liveth in me; and the life which I now live in the flesh I live by the faith of the Son of God, who loved me, and gave himself for me." Galatians 2:20