Re: Research/Implementation of Nested Loop Join optimization - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Research/Implementation of Nested Loop Join optimization
Date
Msg-id 4160.1217032003@sss.pgh.pa.us
Whole thread Raw
In response to Re: Research/Implementation of Nested Loop Join optimization  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Research/Implementation of Nested Loop Join optimization
Re: Research/Implementation of Nested Loop Join optimization
Re: Research/Implementation of Nested Loop Join optimization
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> "Manoel Henrique" <mhenriquesgbd@gmail.com> writes:
>> Yes, I'm relying on the assumption that backwards scan has the same cost as
>> forward scan, why shouldn't it?

> Because hard drives only spin one direction

Good joke, but to be serious: we expect that forward scans will result
in the kernel doing read-ahead, which will allow overlapping of
CPU work to process one page with the I/O to bring in the next page.
A backwards scan will get no such overlapping and thus be up to 2X
slower, unless the kernel is smart enough to do read-ahead for
descending-order read requests.  Which seems not too probable.  A fairly
typical kernel behavior is that read-ahead is triggered by successive
read() requests without any intervening seek(), and this is impossible
for a backward scan.

(Yes, we do optimize out the seek calls in a forward scan.  IIRC it's
done in fd.c.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Research/Implementation of Nested Loop Join optimization
Next
From: daveg
Date:
Subject: Re: Adding WHERE clause to pg_dump