Received: from email03.aon.at (WARSL401PIP7.highway.telekom.at [195.3.96.115]) by postgresql.org (8.11.3/8.11.4) with SMTP id fB58sHm49286 for ; Wed, 5 Dec 2001 03:54:18 -0500 (EST) (envelope-from i.hasenoehrl@aon.at) Received: (qmail 225402 invoked from network); 5 Dec 2001 08:54:17 -0000 Received: from n649p026.adsl.highway.telekom.at (HELO irina) ([62.47.25.26]) (envelope-sender ) by qmail3.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 5 Dec 2001 08:54:17 -0000 Message-ID: <003601c17d6a$398f9100$01011eac@irina> From: =?iso-8859-1?Q?DI_Hasen=F6hrl?= To: "Stephan Szabo" Cc: References: <20011204131843.I6514-100000@megazone23.bigpanda.com> Subject: Re: make query faster?? Date: Wed, 5 Dec 2001 09:52:52 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0033_01C17D72.9B1876A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200112/43 X-Sequence-Number: 5866 This is a multi-part message in MIME format. ------=_NextPart_000_0033_01C17D72.9B1876A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thank you for your response, but I'm not quite clear. Is *sort_mem* the same as postgres' starting option -S *Sortsize*, which is= by default 512Kb At this time I increased sortsize to 1024Kb, but the costs from explain are= the same as before and I can't see, that the query is faster Please, can you explain, what *cost=3D341.63..341.63* means Thank you for your advices -Irina ----- Original Message -----=20 From: Stephan Szabo=20 To: DI Hasen=F6hrl=20 Cc: pgsql-sql@postgresql.org=20 Sent: Tuesday, December 04, 2001 10:26 PM Subject: Re: [SQL] make query faster?? On Tue, 4 Dec 2001, [iso-8859-1] DI Hasen=F6hrl 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. ------=_NextPart_000_0033_01C17D72.9B1876A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thank you for your response, but I'm not q= uite=20 clear.
 
Is *sort_mem* the same as postgres' s= tarting=20 option -S *Sortsize*, which is by default 512Kb
 
At this time I increased sortsize to 1024K= b, but=20 the costs from explain are the same as before and I can't see, that the que= ry is=20 faster
 
Please, can you explain, what *cost=3D341.= 63..341.63*=20 means
 
Thank you for your advices
-Irina
----- Original Message -----
Fro= m:=20 Stephan Szabo
Cc: pgsql-sql@postgresql.org
Sent: Tuesday, December 04, 2001 1= 0:26=20 PM
Subject: Re: [SQL] make query=20 faster??


On Tue, 4 Dec 2001, [iso-8859-1] DI Hasen=F6hrl=20 wrote:

> I've a simple query, but when I use *ORDER BY* it take= s a=20 long time
> till I can see the result.
>
> a_nr is=20 varchar(20) and the primary key of my table artikel.
>
> Plea= se,=20 can someone give me a hint, how to improve my query.

If you have n= ot=20 yet done so, you may want to increase sort_mem in your
postgresql.conf= =20 assuming you have sufficient memory in your machine
(and shared_buffer= s=20 while you're at it). The defaults are fairly low and
you may see a=20 performance gain in general if you raise them to amounts
more reasonab= le=20 for your machine.

> In Bruce Momjian's book I read, that indexe= s are=20 usually not used for
> ORDER BY operations: a sequential scan follo= wed=20 by an explicit sort is
> fatser than an indexscan.
>
>= =20 What's an explicit sort????????

Actually sorting the results of th= e=20 sequence scan rather than using the
fact that the index keys can be go= tten=20 in sorted order to get the rows
in order.

<= /HTML> ------=_NextPart_000_0033_01C17D72.9B1876A0--