Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E967B632872 for ; Tue, 6 Apr 2010 23:33:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 79343-07 for ; Wed, 7 Apr 2010 02:33:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 758A9632868 for ; Tue, 6 Apr 2010 23:33:10 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 66739AE888; Wed, 7 Apr 2010 10:31:19 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail2.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id WyXrp9oKJod5; Wed, 7 Apr 2010 10:31:14 +0800 (WST) Received: from [10.1.1.4] (unknown [124.148.205.28]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 92696AE882; Wed, 7 Apr 2010 10:31:11 +0800 (WST) Message-ID: <4BBBEED4.1000807@postnewspapers.com.au> Date: Wed, 07 Apr 2010 10:32:52 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Brian Cox CC: "pgsql-performance@postgresql.org" Subject: Re: query slow; strace output worrisome References: <4BBB604F.6060005@ca.com> In-Reply-To: <4BBB604F.6060005@ca.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.495 tagged_above=-10 required=5 tests=AWL=-0.385, BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 201004/62 X-Sequence-Number: 38312 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. -- Craig Ringer