Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tazqc-0004re-HE for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 02:15:30 +0000 Received: from outmail148107.authsmtp.com ([62.13.148.107]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tazqa-0002m3-CB for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 02:15:30 +0000 Received: from mail-c226.authsmtp.com (mail-c226.authsmtp.com [62.13.128.226]) by punt12.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id qAL2FPnb057019; Wed, 21 Nov 2012 02:15:25 GMT Received: from ayaki.localdomain (124-148-90-153.dyn.iinet.net.au [124.148.90.153]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id qAL2FII1039605 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 21 Nov 2012 02:15:21 GMT Message-ID: <50AC3935.6060508@2ndQuadrant.com> Date: Wed, 21 Nov 2012 10:15:17 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: Craig James CC: Tom Lane , Claudio Freire , Merlin Moncure , David Greco , "pgsql-performance@postgresql.org" Subject: Re: Hints (was Poor performance using CTE) References: In-Reply-To: X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Server-Quench: 4e83c7b3-3381-11e2-98a9-0025907ec6c5 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiN5VAwpPBRK HVkIKg5MJUcNSQVJ NksacBtFagRbY1ZH HGQLWlZEUF97WGZ/ aQkfbAdZfEtKVxtj UFZIR1FNFgBqBAMA SF9vLhsEDnxHeH15 Y0ZnEHFfXUB9O0Io Sk0HEj8FeGRjYGEC UUENdR5deFJDYx9F aFV2VHRYMmNUYzQC El17HzE3IS4XaDtc WUk1KlUICV4GBDA7 XRULGz4iVVAeRiM8 ZzcaBx90 X-Authentic-SMTP: 61633235383639.1020:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 124.148.90.153/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/220 X-Sequence-Number: 48586 On 11/21/2012 09:35 AM, Craig James wrote: > Why not make an explicit hint syntax and document it? I've still don't > understand why "hint" is a dirty word in Postgres. There are a > half-dozen or so ways in common use to circumvent or correct > sub-optimal plans. > The reason usually given is that hints provide easy workarounds for planner and stats issues, so people don't report problems or fix the underlying problem. Of course, if that's all there was to it, `OFFSET 0` would be made into an error or warning, or ignored and not fenced. The reality is, as you say, that there's a need, because the planner can never be perfect - or rather, if it were nearly perfect, it'd take so long to read the stats and calculate plans that everything would be glacially slow anyway. The planner has to compromise, and so cases will always arise where it needs a little help. I think it's time to admit that and get the syntax in place for CTEs so there's room to optimize them later, rather than cementing CTEs-as-fences in forever as a Pg quirk. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services