Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DA1879FB2EF for ; Tue, 3 Oct 2006 12:30:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 67340-03 for ; Tue, 3 Oct 2006 12:30:44 -0300 (ADT) X-Greylist: delayed 00:20:00.166999 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 237A09FB2FD for ; Tue, 3 Oct 2006 12:30:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from lists.commandprompt.com (host-130.commandprompt.net [207.173.203.130]) by svr4.postgresql.org (Postfix) with ESMTP id E3BF05AF041 for ; Tue, 3 Oct 2006 15:10:40 +0000 (GMT) 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 k93FAZlx012310; Tue, 3 Oct 2006 08:10:35 -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:10:23 -0700 User-Agent: KMail/1.8.3 Cc: Arnaud Lesauvage References: <45224896.7040708@freesurf.fr> In-Reply-To: <45224896.7040708@freesurf.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200610030810.24197.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:10:35 -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/42 X-Sequence-Number: 21171 On October 3, 2006 04:25 am, Arnaud Lesauvage wrote: > Hi List ! > > I have a performance problem, but I am not sure whether it really > is a problem or not. > I am running a fresh install of PostgreSQL 8.1.4 on Windows2000. > The server is a bi-opteron with 2GB of RAM. The PostgreSQL's data > folder is on a RAID-0 array of 2 SATA WD Raptor drives (10.000 > rpm, 8MB cache). > > I have a very simple table, with only ~500 rows : > CREATE TABLE table1 > ( > gid int4 NOT NULL DEFAULT 0, > field1 varchar(45) NOT NULL, > field2 int2 NOT NULL DEFAULT 1, > field3 int2 NOT NULL DEFAULT 0, > field4 int2 NOT NULL DEFAULT 1, > field5 int4 NOT NULL DEFAULT -1, > field6 int4, > field7 int4, > field8 int4, > field9 int2 DEFAULT 1, > CONSTRAINT table1_pkey PRIMARY KEY (gid) > ) > WITHOUT OIDS; > > 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 ! According to your explain analyze, it's taking 0.8 of a milisecond (less than 1 1000th of a second) so I can't see how this can possibly be speed up. > SELECT * FROM table1 WHERE gid in (33,110,65,84,92,94,13,7,68,41); > > EXPLAIN ANALYZE SELECT * FROM table1 WHERE gid in > (33,110,65,84,92,94,13,7,68,41); > > QUERY PLAN > --------------------------------------------------------------------------- >--------------------------------------------------------------------------- > Seq Scan on table1 (cost=0.00..23.69 rows=10 width=35) (actual > time=0.023..0.734 rows=7 loops=1) > Filter: ((gid = 33) OR (gid = 110) OR (gid = 65) OR (gid = 84) > OR (gid = 92) OR (gid = 94) OR (gid = 13) OR (gid = 7) OR (gid = > 68) OR (gid = 41)) > Total runtime: 0.801 ms > (3 rows) > > I have run "VACUUM FULL" on this table many times... I don't know > what to try next ! > What is wrong here (because I hope that something is wrong) ? > Thanks a lot for your help ! > > Regards > -- > Arnaud > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match -- 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/