Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id D1A341ED23D7 for ; Tue, 22 Nov 2011 11:52:32 -0400 (AST) Received: from smtp101.prem.mail.sp1.yahoo.com ([98.136.44.56]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RSse8-0007Sq-5Z for pgsql-sql@postgresql.org; Tue, 22 Nov 2011 15:52:33 +0000 Received: (qmail 16786 invoked from network); 22 Nov 2011 15:52:18 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=jJFtvF+sAiABxQOQLOgXhWYYwpb1mO1QsZ33pu3UIdK6KnzzUsPk24lnxy7ols93rvnEocMUit26jWNU5Y1uNleCiRuBltu3HJN/oEdiUNY9GM5yhZ+/pgIvvbC8i74lIPqeAfFAFa5KV7+fen2fSkF1R8lt/gaoIId9dYDECvk= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1321977138; bh=DY5ccINGM3zM9YltPslk3pJqyj4Z90J6tDDYdHBW32U=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=vmAZtOW18LFakQSciF9jHadlkJMYFnkM5i3KXoM71QZFlofVtrlptB36Jual3GSfqUXAF0ht2vt/vFwXNE12XmquKHKfZXBdpAut3KJaY6wZwduwvnK6tHvidlmidwyv0H0xl30Rl5nm+c15DD7X+EwAlielG30651702CxjnE4= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: ApsQAh4VM1mvRAFhqTtdJqw6oHSSpLmNNqdhziBMJLH01RU 43Owi9fY3oHO.hfCO.OdcR6v8Uh68jnow04r89GOvc7yzIajmyxz4sF0D_kj .QlC5puirq2kiUgzL2ZF4lw2GMdZam32rGi_gDmH4C6UvvNUuHtbpPaS2rC0 WDpeSxYLu3SCRvHRQ2DNNcpMCRQOG_gC7abHoqvtj_LSGVKDMeWn8CiUhgUl q0FkdIArWH22WSaW7l3uAiKoXXtTOInoynvLAJJsLafdEAScly1CJ0vOA2mF Zv6Nd63gJbGMgmMiqJj9cO4DishzdPRNGeBpXo5EMOn2EigmrqljkhslOtrJ vcZmKufpOUFnicy6FY6tORW.9s8xeie6ISw1_rPyPMljXmqZDNJSyDQMzMGU 3a60CMw-- X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.23.188 with login) by smtp101.prem.mail.sp1.yahoo.com with SMTP; 22 Nov 2011 07:52:18 -0800 PST From: "David Johnston" To: References: <4ECBBFEA.4080005@gmail.com> In-Reply-To: <4ECBBFEA.4080005@gmail.com> Subject: Re: Change in 9.1? Date: Tue, 22 Nov 2011 10:52:11 -0500 Message-ID: <070d01cca92e$b34ab830$19e02890$@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQICZe3xtdNghVArmN4STzwbL+53mAJQBEk8lTsNUYA= Content-Language: en-us X-Archive-Number: 201111/75 X-Sequence-Number: 36048 -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Rob Sargent Sent: Tuesday, November 22, 2011 10:30 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Change in 9.1? On 11/22/2011 12:39 AM, Jasmin Dizdarevic wrote: > Hi, > > we have a reporting tool, that sometimes uses this kind of condition. > ...WHERE a.field = a.field > > To explain this: a.field can be filtered by the user. the user can > choose some values. if he does, this condition will be build: > ...WHERE a.field IN (1,2,3) > > If the user doesn't choose any values the * = * condition is used. > > Since 9.1 we're experiencing problems with this construction. Have > there been any changes to the planner regarding this? > > Ty > Regards, Jasmin If it's a commercial product please name that reporting tool: clearly it's to be avoided. If it's an in-house tool clearly it's broken. ------------------------------------------------------------ While probably not optimal Dynamic SQL isn't the easiest thing to construct and so having the occasional sub-optimal construct shouldn't be taken as being wrong - it should at least result in a reasonably optimal, and correct, query plan. The bigger problem is that the OP has utterly failed to describe what kinds of "problems" are being experienced AND has not provided enough data to properly evaluate the situation. Providing a self-contained test case would at least allow people to run the query and see what is happening...and at a minimum a query plan (with analyze ideally) - from both versions - would at least allow some degree of analysis even without a full test-case. Since the data matters proving all of: a test case, AND EXPLAIN ANALYZE results, AND a description of what is taken as being a problem, is necessary to provide suggestions. David J.