pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Gaspar <andi@softnrg.dnttm.ro>
To: Dave Held <dave.held@arrayservicesgrp.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Sort and index
Date: Mon, 18 Apr 2005 19:11:38 +0300
Message-ID: <4263DC3A.5070509@softnrg.dnttm.ro> (raw)
In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184B6@asg002.asg.local>
References: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184B6@asg002.asg.local>

Thanks for the quick response
Andrei

Dave Held wrote:

>>-----Original Message-----
>>From: Andrei Gaspar [mailto:andi@softnrg.dnttm.ro]
>>Sent: Monday, April 18, 2005 10:36 AM
>>To: pgsql-performance@postgresql.org
>>Subject: [PERFORM] Sort and index
>>
>>I thought that an index can be used for sorting.
>>I'm a little confused about the following result:
>>
>>create index OperationsName on Operations(cOperationName);
>>explain SELECT * FROM Operations ORDER BY cOperationName;
>>                              QUERY PLAN
>>--------------------------------------------------------------
>>---------
>> Sort  (cost=185.37..189.20 rows=1532 width=498)
>>   Sort Key: coperationname
>>   ->  Seq Scan on operations  (cost=0.00..104.32 rows=1532 width=498)
>>(3 rows)
>>
>>Is this supposed to be so?
>>    
>>
>
>Since you are fetching the entire table, you are touching all the rows.
>If the query were to fetch the rows in index order, it would be seeking
>all over the table's tracks.  By fetching in sequence order, it has a
>much better chance of fetching rows in a way that minimizes head seeks.
>Since disk I/O is generally 10-100x slower than RAM, the in-memory sort 
>can be surprisingly slow and still beat indexed disk access.  Of course,
>this is only true if the table can fit and be sorted entirely in memory
>(which, with 1500 rows, probably can).
>
>__
>David B. Held
>Software Engineer/Array Services Group
>200 14th Ave. East,  Sartell, MN 56377
>320.534.3637 320.253.7800 800.752.8129
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>
>  
>


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.15 - Release Date: 4/16/2005




view thread (17+ messages)  latest in thread

Message-ID: <4263DC3A.5070509@softnrg.dnttm.ro>
Permalink:  ../4263DC3A.5070509@softnrg.dnttm.ro/
Also on:    postgresql.org/message-id/4263DC3A.5070509@softnrg.dnttm.ro

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: andi@softnrg.dnttm.ro, dave.held@arrayservicesgrp.com
  Subject: Re: Sort and index
  In-Reply-To: <4263DC3A.5070509@softnrg.dnttm.ro>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox