Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 165D89FB1E8 for ; Tue, 3 Oct 2006 12:35:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 35767-02 for ; Tue, 3 Oct 2006 15:35:12 +0000 (UTC) X-Greylist: delayed 00:24:31.188258 by SQLgrey- Received: from lists.commandprompt.com (host-130.commandprompt.net [207.173.203.130]) by postgresql.org (Postfix) with ESMTP id B6F139FB1BF for ; Tue, 3 Oct 2006 12:35:11 -0300 (ADT) Received: from freebsd4.homenet.dbitech.bc.ca (d207-216-64-62.bchsia.telus.net [207.216.64.62]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id k93FZCW5012871 for ; Tue, 3 Oct 2006 08:35:13 -0700 From: Darcy Buskermolen Organization: CommandPrompt, Inc To: pgsql-performance@postgresql.org Subject: Re: Poor performance on very simple query ? Date: Tue, 3 Oct 2006 08:35:05 -0700 User-Agent: KMail/1.8.3 References: <45224896.7040708@freesurf.fr> <3B2D7EC8-8E9B-46A3-A15F-4F554E10EA3B@purefiction.net> In-Reply-To: <3B2D7EC8-8E9B-46A3-A15F-4F554E10EA3B@purefiction.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200610030835.06089.darcyb@commandprompt.com> X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Tue, 03 Oct 2006 08:35:13 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/43 X-Sequence-Number: 21172 On October 3, 2006 05:08 am, Alexander Staubo wrote: > On Oct 3, 2006, at 13:25 , Arnaud Lesauvage wrote: > > The problem is that simple select queries with the primary key in > > the WHERE statement take very long to run. > > For example, this query returns only 7 rows and takes about 1 > > second to run ! > > SELECT * FROM table1 WHERE gid in (33,110,65,84,92,94,13,7,68,41); > > This is a very small table, but generally speaking, such queries > benefit from an index; eg., > > create index table1_gid on table1 (gid); gid is is a PRIMARY KEY, so it will already have an index in place. > > Note that PostgreSQL may still perform a sequential scan if it thinks > this has a lower cost, eg. for small tables that span just a few pages. > > > I have run "VACUUM FULL" on this table many times... I don't know > > what to try next ! > > PostgreSQL's query planner relies on table statistics to perform > certain optimizations; make sure you run "analyze table1". > > Alexander. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: 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 -- Darcy Buskermolen Command Prompt, Inc. Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 PostgreSQL solutions since 1997 http://www.commandprompt.com/