Re: The optimizer is too smart for me - How can I trick it? - Mailing list pgsql-general

From Peter Vanderborght
Subject Re: The optimizer is too smart for me - How can I trick it?
Date
Msg-id 007901c8c269$d7a5c8a0$88c8a8c0@TAATU.local
Whole thread Raw
In response to The optimizer is too smart for me - How can I trick it?  ("Peter Vanderborght" <peter.vanderborght@taatu.com>)
List pgsql-general
GREAT!!!
Just "offset 0" in the subquery did the trick!

I had already been playing with a stored proc, but that's way more messy
than this.

Thanks a million!
Peter

-----Original Message-----
From: Adam Rich [mailto:adam.r@sbcglobal.net]
Sent: 30 May 2008 17:14
To: peter.vanderborght@taatu.com; pgsql-general@postgresql.org
Subject: RE: [GENERAL] The optimizer is too smart for me - How can I trick
it?


> I've implemented Depesz's running total function
> (http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-
> sum-in-
> one-query/) in my DB, which works great.
> Now what I want to do is get the running total for a certain statement
> and then do a subselect on that result so to get a non-zero start on a
> function.
>
> Instead, the optimizer sees what I'm trying to do, moves the where
> clause inside the subquery and my output becomes
>
> What can I do to tell the optimizer to keep its hands off my query or
> at least get it to not optimize?
>

I think if you add a LIMIT/OFFSET clause to your subquery, the planner
will leave it alone.






pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Mediawiki 1.10 and PG 8.3 upgrade
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Mediawiki 1.10 and PG 8.3 upgrade