Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vyqz4-0003AW-K4 for pgsql-performance@arkaria.postgresql.org; Thu, 02 Jan 2014 22:43:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vyqz3-0007fS-82 for pgsql-performance@arkaria.postgresql.org; Thu, 02 Jan 2014 22:43:21 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vyqz2-0007fJ-44 for pgsql-performance@postgresql.org; Thu, 02 Jan 2014 22:43:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vyqyv-0007zo-Vb for pgsql-performance@postgresql.org; Thu, 02 Jan 2014 22:43:19 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s02MhCGd018381; Thu, 2 Jan 2014 17:43:12 -0500 From: Tom Lane To: Jeff Janes cc: Thomas Mayer , pgsql-performance Subject: Re: window function induces full table scan In-reply-to: References: <52C5DAD1.20109@student.kit.edu> <17191.1388699570@sss.pgh.pa.us> Comments: In-reply-to Jeff Janes message dated "Thu, 02 Jan 2014 14:26:31 -0800" Date: Thu, 02 Jan 2014 17:43:12 -0500 Message-ID: <18380.1388702592@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Jeff Janes writes: > On Thu, Jan 2, 2014 at 1:52 PM, Tom Lane wrote: >> It's possible that in the specific case you exhibit here, pushing down >> the clause wouldn't result in changes in the window function's output for >> the selected rows, but the optimizer doesn't have enough knowledge about >> window functions to determine that. > A restriction in the WHERE clause which corresponds to the PARTITION BY > should be pushable, no? I think it doesn't need to understand the internal > semantics of the window function itself, just of the PARTITION BY, which > should be doable, at least in principle. If the restriction clause must give the same answer for any two rows of the same partition, then yeah, we could in principle push it down without knowing anything about the specific window function. It'd be a less than trivial test to make, I think. In any case, it's not a "bug" that the optimizer doesn't do this currently. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance