Re: possible optimizations - pushing filter before aggregation - Mailing list pgsql-hackers

From Mithun Cy
Subject Re: possible optimizations - pushing filter before aggregation
Date
Msg-id CAD__OuhP04+=mn0DGOytpVM_g_qWWGwJCG8DXnoJSAkhMCVk0w@mail.gmail.com
Whole thread Raw
In response to Re: possible optimizations - pushing filter before aggregation  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: possible optimizations - pushing filter before aggregation
List pgsql-hackers
On Sat, Nov 19, 2016 at 8:59 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:



SELECT MIN(a) m FROM
   (SELECT a FROM t WHERE a=2) AS v(a)

The subquery is going to return an intermediate result of:

V:A
---
2

And the minimum of that is 2, which is the wrong answer.

yes, you have true,

In above case wondering if we could do this

Min(a) = 2 is the condition, generate condition "a <= 2" and push it down as scan key. Since pushed down condition is lossy one for us ( it gives values < 2), finally do a recheck of "Min(a) = 2".

For Max(a) = 2 we can have "a >=2",

If both are given we can combine them appropriately. 

--
Thanks and Regards
Mithun C Y

pgsql-hackers by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: Patch to implement pg_current_logfile() function
Next
From: Andrew Dunstan
Date:
Subject: Re: Mail thread references in commits