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

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: <peter(dot)vanderborght(at)taatu(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: The optimizer is too smart for me - How can I trick it?
Date: 2008-05-30 15:13:49
Message-ID: 026301c8c267$c3ecb870$4bc62950$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Vanderborght 2008-05-30 15:28:41 Re: The optimizer is too smart for me - How can I trick it?
Previous Message Jon Lapham 2008-05-30 15:09:13 Re: Mediawiki 1.10 and PG 8.3 upgrade