Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 32A8C6324E2 for ; Mon, 29 Mar 2010 15:02:15 -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 96986-07 for ; Mon, 29 Mar 2010 18:02:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f225.google.com (mail-fx0-f225.google.com [209.85.220.225]) by mail.postgresql.org (Postfix) with ESMTP id 924DE632269 for ; Mon, 29 Mar 2010 15:02:04 -0300 (ADT) Received: by fxm25 with SMTP id 25so76586fxm.3 for ; Mon, 29 Mar 2010 11:02:03 -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=V7dE1a5WSWXG05TJnlG2NbrFehRQGs5HyxzASj9DUck=; b=oKcm1hx4DZuAHjVDm9Q9wmYcgn7RcEfqSA2mZJSKpnAgISigKm0g7dMSd9fBy6cZEU QfAqGWAJ84DU81W4dc3pg791Ctew0/YpIYE/fctAVZZcJNDmyTVl5bJPgdqDxa8BRufg 7yC37MpYPj4PCRs+nUiseYFVRKTv83gktNdY0= 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=YEmQ9nXe7rkSJ+/d4ibaSY7Golumh718/aoJNgykF6TEszSDAzcbgJoWrltKLwfSH0 xo6r+hLbT+d9fAnoWrMuTPwSLHrCIUtlA4nRPy3++l192BfCh8MqJPvbHh8Cg8AErrAA nUveFly+siOeGZ/EEIJCZsjUI72iTmXq7+cBY= MIME-Version: 1.0 Received: by 10.239.161.83 with HTTP; Mon, 29 Mar 2010 11:02:03 -0700 (PDT) In-Reply-To: References: Date: Mon, 29 Mar 2010 14:02:03 -0400 Received: by 10.239.135.16 with SMTP id b16mr419480hbb.204.1269885723258; Mon, 29 Mar 2010 11:02:03 -0700 (PDT) Message-ID: <603c8f071003291102g778afc2fvda0fc281454526c9@mail.gmail.com> Subject: Re: experiments in query optimization From: Robert Haas To: Faheem Mitha Cc: 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: 201003/376 X-Sequence-Number: 38201 On Thu, Mar 25, 2010 at 3:57 PM, Faheem Mitha wrote: > > Hi everyone, > > I've been trying to reduce both memory usage and runtime for a query. > Comments/suggestions gratefully received. Details are at > > http://bulldog.duhs.duke.edu/~faheem/snppy/opt.pdf > > See particularly Section 1 - Background and Discussion. > > If you want a text version, see > > http://bulldog.duhs.duke.edu/~faheem/snppy/opt.tex > > For background see > > http://bulldog.duhs.duke.edu/~faheem/snppy/diag.pdf (text version > http://bulldog.duhs.duke.edu/~faheem/snppy/diag.tex) and > http://bulldog.duhs.duke.edu/~faheem/snppy/snppy.pdf > > Please CC any replies to me at the above email address. Thanks. Didn't you (or someone) post about these queries before? It's not really too clear to me from reading this what specific questions you're trying to answer. One random thought: WHERE row_number() = 1 is not too efficient. Try using LIMIT or DISTINCT ON instead. If you're concerned about memory usage, try reducing work_mem; you've probably got it set to something huge. You might need to create some indices, too. ...Robert