Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 670BC1A6A984 for ; Sat, 21 Jul 2012 05:31:11 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SsV5f-0007pq-Ij for pgsql-performance@postgresql.org; Sat, 21 Jul 2012 08:31:10 +0000 Received: by pbbrp8 with SMTP id rp8so7538294pbb.19 for ; Sat, 21 Jul 2012 01:30:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=xptZIaK204kzIcXX/r08WpOyAhukD3x97aof9HyyPBM=; b=VIxxrjVClQRTQyGzxmf/aj0zLx4iTnpShDcJhWev2aOmAytmKsT8u+feuVQlxmlzmd SgVp2pcq86nb3C1s/gi6vY+ppUq4qz1rKzyH1zbSUxyLKZ5/UaunGdCkm1SbyxvnYuHG peABjahtBPsn4Fqs7C6FFnc/10y4Lydln3zs//9YkpbQH/ZUihefuMNCJ5MLyOe2GJ8S QMyDVBvDHZG2xzOPbMIfLaE/NZDQuN3kPyUmszIdzf9SKZsLBf/nL2HAz/dxUAjbTv1p AGoJkc4E6UNOpmO4wb02z8xi3kFsbqOMjp3j7Lst3srfBiQwnRA99cRMi5RRwK5BZYXc 1KvA== Received: by 10.68.225.6 with SMTP id rg6mr20282029pbc.100.1342859450189; Sat, 21 Jul 2012 01:30:50 -0700 (PDT) Received: from ayaki.localdomain (124-169-186-146.dyn.iinet.net.au. [124.169.186.146]) by mx.google.com with ESMTPS id nh8sm5644908pbc.60.2012.07.21.01.30.47 (version=SSLv3 cipher=OTHER); Sat, 21 Jul 2012 01:30:48 -0700 (PDT) Message-ID: <500A68B4.6060309@ringerc.id.au> Date: Sat, 21 Jul 2012 16:30:44 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Andy Halsall CC: postgres performance Subject: Re: query overhead References: , <5000E75A.6030108@ringerc.id.au> , <500428AD.5060400@ringerc.id.au> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlY0ED++y5qvfHg56aDZvqmAHQwZYGXwfYjnFOoVwZF40AZo9opwvlAMXqCHRwY0vql2LmR X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/252 X-Sequence-Number: 47433 On 07/17/2012 11:33 PM, Andy Halsall wrote: > > If you're working with ISAM-like access though, cursors may well be > very helpful for you. It's a pity for your app that Pg doesn't support > cursors that see changes committed after cursor creation, since these > are ideal when emulating ISAM "next record" / "previous record" access > models. They're still suitable for tasks where you know the app > doesn't need to see concurrently modified data, though. > > > That's right, that would've been ideal behaviour for us. We're going > to manage our own shared cache in the application layer to give > similar functionality. We have lots of reads but fewer writes. How have you gone with this? I'm curious. By the way, when replying it's the convention to indent the text written by the person you're replying to, not indent your own text. It's kind of hard to read. > > In the context of what we've been talking about, we're reading a set > of information which is ordered in a reasonably complex way. Set is > about 10000 records and requires a table join. This sort takes a while > as it heap scans - couldn't persuade it to use indexes. > > > Having read the set, the application "gets next" until the end. To > start with we were re-establishing the set (minus the previous record) > and choosing the first (LIMIT 1) on each "get next" - obviously a > non-starter. We moved to caching the record keys for the set and only > visiting the database for the specific records on each "get next" - > hence the questions about round trip overhead for small queries. Given that pattern, why aren't you using a cursor? Do you need to see concurrent changes? Is the cursor just held open too long, affecting autovacum? -- Craig Ringer