X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 855B79FA38F for ; Tue, 13 Jun 2006 23:13:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 69865-02 for ; Tue, 13 Jun 2006 23:13:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id DB69A9FA1A8 for ; Tue, 13 Jun 2006 23:13:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k5E2DOx6018844; Tue, 13 Jun 2006 22:13:24 -0400 (EDT) To: "Shaun Thomas" cc: "Jim C. Nasby" , pgsql-performance@postgresql.org Subject: Re: Confirmation of bad query plan generated by 7.4 In-reply-to: <448EF8B2.8F27.00A9.0@leapfrogonline.com> References: <9119.1150222168@sss.pgh.pa.us> <448EDFC4.8F27.00A9.0@leapfrogonline.com> <20060613211347.GB34196@pervasive.com> <448EE95D.8F27.00A9.0@leapfrogonline.com> <20060613215418.GI34196@pervasive.com> <448EF8B2.8F27.00A9.0@leapfrogonline.com> Comments: In-reply-to "Shaun Thomas" message dated "Tue, 13 Jun 2006 17:41:06 -0500" Date: Tue, 13 Jun 2006 22:13:24 -0400 Message-ID: <18843.1150251204@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/234 X-Sequence-Number: 19591 "Shaun Thomas" writes: > I can see the planner not liking the results of a function, > but a variable? That's a static value! Read what you wrote, and rethink... If you're desperate you can construct a query string with the variable value embedded as a literal, and then EXECUTE that. This isn't a great solution since it forces a re-plan on every execution. We've occasionally debated ways to do it better, but no such improvement will ever appear in 7.4 ;-) regards, tom lane