X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3091E52814 for ; Wed, 8 Jun 2005 18:49:16 -0300 (ADT) 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 57259-06 for ; Wed, 8 Jun 2005 21:49:08 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id EA78A52896 for ; Wed, 8 Jun 2005 18:49:05 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Dg8KX-0006bV-Aq for pgsql-sql@postgresql.org; Wed, 08 Jun 2005 23:43:24 +0200 Received: from ppp-62-245-208-158.mnet-online.de ([62.245.208.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jun 2005 23:43:21 +0200 Received: from spam_eater by ppp-62-245-208-158.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jun 2005 23:43:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: SELECT very slow Date: Wed, 08 Jun 2005 23:46:41 +0200 Lines: 39 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ppp-62-245-208-158.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7.6) Gecko/20050319 Mnenhy/0.6.0.104 X-Accept-Language: de, en X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/119 X-Sequence-Number: 21720 Hello, I have a table with roughly 100,000 rows (four varchar(100) columns). This is basically test data I generated for something else. I'm using JDBC to access PG (but the behaviour is the same with psql). The problem is, that a SELECT * FROM foobar; takes ages (roughly 3 minutes) to return the first row. I played around with the fetchSize() to disable the result set caching in the Java program first (before I tried psql) but that did not change anything. It seems that PG is actually building up the full result set in the background before delivering the first row. But I cannot see any of the processes (neither my Java process nor the PG processes) using a lot of memory - which I would expect if a result set of that size is created. I need to test a program which should process large result sets (without loading it into memory) and waiting nearly three minutes before it actually starts working is a bit annoying :) A SELECT count(*) FROM foobar is quite fast (about 2 seconds) I hate to say this, but the same SELECT returns the first row more or less instantly with Firebird, SQL Server (MSDE) and HSQLDB. Is there anything I can do, to convince PG to return the first row more quickly? I tried a VACUUM FULL, no change. I increased the shared_buffers to 1000, no improvement either. The execution plan is not really surprising: Seq Scan on foobar (cost=0.00..2510.04 rows=117504 width=63) I'm using PG 8.0.3 on Win2K. Thanks in advance Thomas