Received: from megazone.bigpanda.com ([63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fB4LQcm17580 for ; Tue, 4 Dec 2001 16:26:38 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A4B0ED5E6; Tue, 4 Dec 2001 13:26:39 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9A6315BEA; Tue, 4 Dec 2001 13:26:39 -0800 (PST) Date: Tue, 4 Dec 2001 13:26:39 -0800 (PST) From: Stephan Szabo To: =?iso-8859-1?Q?DI_Hasen=F6hrl?= Cc: Subject: Re: make query faster?? In-Reply-To: <004a01c17d06$5f61b840$01011eac@irina> Message-ID: <20011204131843.I6514-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by postgresql.org id fB4LQqL17590 X-Archive-Number: 200112/39 X-Sequence-Number: 5862 On Tue, 4 Dec 2001, [iso-8859-1] DI Hasenöhrl wrote: > I've a simple query, but when I use *ORDER BY* it takes a long time > till I can see the result. > > a_nr is varchar(20) and the primary key of my table artikel. > > Please, can someone give me a hint, how to improve my query. If you have not yet done so, you may want to increase sort_mem in your postgresql.conf assuming you have sufficient memory in your machine (and shared_buffers while you're at it). The defaults are fairly low and you may see a performance gain in general if you raise them to amounts more reasonable for your machine. > In Bruce Momjian's book I read, that indexes are usually not used for > ORDER BY operations: a sequential scan followed by an explicit sort is > fatser than an indexscan. > > What's an explicit sort???????? Actually sorting the results of the sequence scan rather than using the fact that the index keys can be gotten in sorted order to get the rows in order.