Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E9171633D53 for ; Wed, 7 Apr 2010 15:39:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 05246-02 for ; Wed, 7 Apr 2010 18:39:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pw0-f46.google.com (mail-pw0-f46.google.com [209.85.160.46]) by mail.postgresql.org (Postfix) with ESMTP id 5F61E633AAC for ; Wed, 7 Apr 2010 15:39:28 -0300 (ADT) Received: by pwj9 with SMTP id 9so1261023pwj.19 for ; Wed, 07 Apr 2010 11:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=e5few02f6sjGmmteCawBl4cnVMbYRFwnCjMSrPwHNDM=; b=l72TGrO3alXgfavfUurlJqF9WkjwU6CqRtEjwHhxK2YaqPmifVJ0UU9WdHsJjcoZMv RQ1Zta3JZ4A2h+SDMMctgFCGVWTrb7Tuaw052XkB4AUa+EZwARriC7kY2aV0t0B5aWdx VBMSN9+yxjPzrvmKXNStb/jxk3nGpkIjfT06A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=TdhcQ2F6JTQLqUc4/VDk5ijuyx5ZolPZf0rhEf0z3qe0Ewex1NyeQYlLdWQf+X1u3R gGi2RKhhrzYDQh0uqzV5EXQLU8Y2QP8rwjjjrgHy2Jgp6DxQjccgtcDbgWiaS9OTVhfD OHKfUpzx6GlXhdQraq+EGGbWTUmDDLrFO4D24= MIME-Version: 1.0 Received: by 10.231.19.69 with HTTP; Wed, 7 Apr 2010 11:39:26 -0700 (PDT) In-Reply-To: <4BBBEED4.1000807@postnewspapers.com.au> References: <4BBB604F.6060005@ca.com> <4BBBEED4.1000807@postnewspapers.com.au> Date: Wed, 7 Apr 2010 14:39:26 -0400 Received: by 10.141.188.41 with SMTP id q41mr7779569rvp.203.1270665567121; Wed, 07 Apr 2010 11:39:27 -0700 (PDT) Message-ID: Subject: Re: query slow; strace output worrisome From: Robert Haas To: Craig Ringer Cc: Brian Cox , "pgsql-performance@postgresql.org" Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201004/70 X-Sequence-Number: 38320 On Tue, Apr 6, 2010 at 10:32 PM, Craig Ringer wrote: > On 7/04/2010 12:24 AM, Brian Cox wrote: >> >> On 04/06/2010 01:18 AM, Craig Ringer [craig@postnewspapers.com.au] wrote: >>> >>> I'm wondering if the issue is with strace rather than Pg. That is to >>> say, that strace is trying to print: >> >> Thanks, Craig: I do think that this is a strace issue. >> >>> As for what Pg is doing: creat() returns -1 on error and a file >>> descriptor otherwise, so the return value appears to indicate success. >>> I'm kind of wondering what the Pg backend is actually _doing_ though - >>> if it was using sort temp files you'd expect >>> open()/write()/read()/close() not just creat() calls. >> >> My quesiton exactly: what is the backend doing calling creat() over and >> over again? Note that this query does complete -- in 30-40 mins. > > I'd assume it was tempfile creation, but for the fact that there's nothing > but creat() calls. > > However, we can't trust strace. There may be more going on that is being > hidden from strace via limitations on the ptrace syscall imposed by SELinux > / AppArmor / whatever. > > I suggest turning on the logging options in Pg that report use of tempfiles > and disk-spilled sorts, then have a look and see if Pg is in fact using > on-disk temp files for sorts or materialized data sets. > > If it is, you might find that increasing work_mem helps your query out. Yeah, I'd start with EXPLAIN and then, if you can wait long enough, EXPLAIN ANALYZE. You'll probably find it's doing a big sort or a big hash join. ...Robert