odd postgresql performance (excessive lseek) - Mailing list pgsql-performance

From Jon Nelson
Subject odd postgresql performance (excessive lseek)
Date
Msg-id AANLkTikS8ptnCVJK+6u-Z3Xh8WMKdgq+T+trdxt3xgYB@mail.gmail.com
Whole thread Raw
Responses Re: odd postgresql performance (excessive lseek)  (Jon Nelson <jnelson+pgsql@jamponi.net>)
List pgsql-performance
postgres 8.4.4 on openSUSE 11.3 (2.6.36rc7, x86_64).

I was watching a fairly large query run and observed that the disk
light went out. I checked 'top' and postgres was using 100% CPU so I
strace'd the running process.
This is what I saw:

lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(87, 0, SEEK_END)                  = 585531392
lseek(94, 270680064, SEEK_SET)          = 270680064
read(94, "<elided>"..., 8192) = 8192

and I observed that pattern quite a bit.

I know lseek is cheap, but a superfluous systemcall is a superfluous
systemcall, and over a short period amounted to 37% (according to
strace) of the time spent in the system.

What's with the excess calls to lseek?

The query plan was a nested loop anti-join (on purpose).

--
Jon

pgsql-performance by date:

Previous
From: Jesper Krogh
Date:
Subject: Re: Slow count(*) again...
Next
From: Samuel Gendler
Date:
Subject: Re: oracle to psql migration - slow query in postgres