Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4E1272E010C for ; Fri, 14 Dec 2007 23:53:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91993-01 for ; Fri, 14 Dec 2007 23:53:19 -0400 (AST) Received: from serv01.siteground137.com (ns1.siteground137.com [67.15.250.10]) by postgresql.org (Postfix) with ESMTP id 4F5ED2E00DB for ; Fri, 14 Dec 2007 23:53:19 -0400 (AST) Received: from cragnux.laika.com ([209.162.219.253]:54330 helo=dogma.ljc.laika.com) by serv01.siteground137.com with esmtpa (Exim 4.68) (envelope-from ) id 1J3O5V-0005dQ-31; Fri, 14 Dec 2007 21:53:17 -0600 Subject: Re: explanation for seeks in VACUUM From: Jeff Davis To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <15476.1197677090@sss.pgh.pa.us> References: <1197660594.28804.276.camel@dogma.ljc.laika.com> <15476.1197677090@sss.pgh.pa.us> Content-Type: text/plain Date: Fri, 14 Dec 2007 19:53:14 -0800 Message-Id: <1197690794.28804.321.camel@dogma.ljc.laika.com> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-7) Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - serv01.siteground137.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - j-davis.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/235 X-Sequence-Number: 28051 On Fri, 2007-12-14 at 19:04 -0500, Tom Lane wrote: > Jeff Davis writes: > > Where am I going wrong? Are many of these lseeks no-ops or something? > > They're not supposed to be, but if you only tracked seeks and not > reads or writes, it's hard to be sure what's going on. The seeks were comparable to reads and writes, which is what surprised me: $ ktrace -p 42440; sleep 5; ktrace -C $ kdump -f ktrace.out | grep "GIO fd 38 read" | wc -l 11479 $ kdump -f ktrace.out | grep "GIO fd 38 wrote" | wc -l 11480 $ kdump -f ktrace.out | grep "lseek.0x26" | wc -l 22960 > 8.2's VACUUM should process a btree index (this is a btree index no?) > in physical order, so I'd expect lseeks only when a page is already in > buffers --- at least on the read side. On the write side things might > be a great deal less predictable. You're cleaning out about one tuple > in 30, so the odds are that nearly every index page is getting dirtied, > and they're going to need to be written sometime. Actually, the table I was VACUUMing had both btree and GIN indexes, and I'm not entirely sure which one was happening at the time. I will investigate more. My intuition tells me that, if the pages are being read and dirtied sequentially, it would be able to write mostly sequentially (at least in theory). In the box that was causing the problem (which had more constrained memory than my reproduced case), it seemed to be swamped by random I/O -- low CPU usage, and low disk usage (about 1-2 MB/s write), yet VACUUM would take forever and the box would appear very sluggish. Regards, Jeff Davis