pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Guillaume Cottenceau <gc@mnc.ch>
Cc: pgsql-performance@postgresql.org
Subject: Re: Poor performance on seq scan
Date: Tue, 12 Sep 2006 14:24:24 +0100
Message-ID: <4506B508.80806@enterprisedb.com> (raw)
In-Reply-To: <87y7spw8v9.fsf@meuh.mnc.lan>
References: <450684EC.4090304@designaproduct.biz>
	<4506902C.7090407@enterprisedb.com>
	<4506A9E7.2060303@designaproduct.biz>
	<87y7spw8v9.fsf@meuh.mnc.lan>

Guillaume Cottenceau wrote:
> Laszlo Nagy <gandalf 'at' designaproduct.biz> writes:
>   
>>> Probably, but PostgreSQL doesn't know how to do that. Even if it
>>> did, it depends on how many matches there is. If you scan the index
>>> and then fetch the matching rows from the heap, you're doing random
>>> I/O to the heap. That becomes slower than scanning the heap
>>> sequentially if you're going to get more than a few hits.
>>>       
>> I have 700 000 rows in the table, and usually there are less than 500
>> hits. So probably using a "seq index scan" would be faster. :-) Now I
>>     
>
> You can confirm this idea by temporarily disabling sequential
> scans. Have a look at this chapter:
>   

I don't think it will anyway do a "seq index scan" as Laszlo envisions. 
PostgreSQL cannot do "fetch index tuple and apply %Mug% to it. If it 
matches, fetch heap tuple". Even if you disable sequential scans, it's 
still going to fetch every heap tuple to see if it matches "%Mug%". It's 
just going to do it in index order, which is slower than a seq scan.

BTW:  in addition to setting enable_seqscan=false, you probably have to 
add a dummy where-clause like "name > ''" to force the index scan.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com




view thread (26+ messages)  latest in thread

Message-ID: <4506B508.80806@enterprisedb.com>
Permalink:  ../4506B508.80806@enterprisedb.com/
Also on:    postgresql.org/message-id/4506B508.80806@enterprisedb.com

 · 

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: heikki@enterprisedb.com, gc@mnc.ch
  Subject: Re: Poor performance on seq scan
  In-Reply-To: <4506B508.80806@enterprisedb.com>

* 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