Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 21BC6632951 for ; Thu, 27 May 2010 15:29:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 73511-04 for ; Thu, 27 May 2010 18:28:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f189.google.com (mail-yw0-f189.google.com [209.85.211.189]) by mail.postgresql.org (Postfix) with ESMTP id 88FAC6324C3 for ; Thu, 27 May 2010 15:28:57 -0300 (ADT) Received: by ywh27 with SMTP id 27so300ywh.20 for ; Thu, 27 May 2010 11:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=V3+gkdClLcEQ1w3wtAYBVvNHrz3bbyX44FN+wK2OS8w=; b=Ps/wOTKjQAVrF3KO48BRnZQase5MCCOyjeP7Y4TfvVnbeTLSiVbhcLyWyGUWpPw20L gtPHWGR2KP6RMGFpFFUo1uSBxDGwYr9lMm/71xJypJ6Ey5J6OyFIhhnyKU71UXshZwLZ DGkAoVbPjN4XHeiyus5f7tCtJB89XjOeeO8EI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=xRA0pWFWzPfuyUw/mWlDN/ubYHjiqqJyyrjenwi6ofRcFM87QiMv1SQv1OHPP3pdw6 spOo5gMmXoKm/+l4mX+89wym42kuWftXga6mmugK/56Cwni/Oe0aiI6/lxJHos/rf70n BTmguVLHQEEv1EnC8CO3xl6j85TvOf8EZgewg= Received: by 10.150.209.7 with SMTP id h7mr403804ybg.14.1274984936113; Thu, 27 May 2010 11:28:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.112.8 with HTTP; Thu, 27 May 2010 11:28:36 -0700 (PDT) In-Reply-To: References: From: =?ISO-8859-1?Q?C=E9dric_Villemain?= Date: Thu, 27 May 2010 20:28:36 +0200 Message-ID: Subject: Re: Random Page Cost and Planner To: David Jarvis Cc: Bryan Hinton , pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_20=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201005/237 X-Sequence-Number: 38821 2010/5/27 David Jarvis : > Salut, C=E9dric. > >> I wonder what the plan will be if you replace sc.taken_* in : >> m.taken BETWEEN sc.taken_start AND sc.taken_end >> by values. It might help the planner... > > That is a fairly important restriction. I will try making it > (year1||'-01-01')::date, but I have no constant value for it -- it is a > user-supplied parameter. And then there's the year wrapping problem, too, > where the ending year will differ from the starting year in certain cases= . > (Like querying rows between Dec 22, 1900 to Mar 22 1901 rather than Mar 2= 2 > 1900 to Dec 22 1900. The first query is the winter season and the second > query is all seasons except winter.) Ah, I though that you had a start and an end provided (so able to put them in the query) > >> >> Also, I'll consider explicit ordered join but I admit I haven't read >> the whole thread (in particular the table size). > > C'est une grosse table. Pres que 40 million lines; il y a sept tableau co= mme > ca. > > I tried an explicit join in the past: it did not help much. But that was > before everything was running this fast, so now that the system performs > differently, maybe it will help? yes. the documentation is fine for this topic : http://www.postgresql.org/docs/8.4/interactive/explicit-joins.html Consider the parameter to explicit join order (you can set it per sql sessi= on). You know your data and know what are the tables with less results to join first. ;) > > Dave > > --=20 C=E9dric Villemain 2ndQuadrant http://2ndQuadrant.fr/ PostgreSQL : Expertise, Formation et Support