Re: Poor performance on seq scan

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Guillaume Cottenceau <gc(at)mnc(dot)ch>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Poor performance on seq scan
Date: 2006-09-12 13:32:55
Message-ID: 20060912133254.GC11324@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Heikki Linnakangas wrote:
> 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.

Are you saying that an indexscan "Filter" only acts after getting the
heap tuple? If that's the case, then there's room for optimization
here, namely if the affected column is part of the index key, then we
could do the filtering before fetching the heap tuple.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Heikki Linnakangas 2006-09-12 13:45:06 Re: Poor performance on seq scan
Previous Message Heikki Linnakangas 2006-09-12 13:24:24 Re: Poor performance on seq scan