*** a/src/backend/optimizer/path/allpaths.c
--- b/src/backend/optimizer/path/allpaths.c
***************
*** 1692,1698 **** subquery_is_pushdown_safe(Query *subquery, Query *topquery,
  {
  	SetOperationStmt *topop;
  
! 	/* Check point 1 */
  	if (subquery->limitOffset != NULL || subquery->limitCount != NULL)
  		return false;
  
--- 1692,1698 ----
  {
  	SetOperationStmt *topop;
  
! 	/* Pushdown is unsafe if we have a LIMIT/OFFSET clause */
  	if (subquery->limitOffset != NULL || subquery->limitCount != NULL)
  		return false;
  
***************
*** 1794,1802 **** recurse_pushdown_safe(Node *setOp, Query *topquery,
   *
   * 4. If the subquery has windowing functions we are able to push down any
   * quals that are referenced in all of the subquery's window PARTITION BY
!  * clauses. This is permitted as window partitions are completed isolated
   * from each other and removing records from unneeded partitions early has
!  * no affect on the query results.
   */
  static void
  check_output_expressions(Query *subquery, bool *unsafeColumns)
--- 1794,1802 ----
   *
   * 4. If the subquery has windowing functions we are able to push down any
   * quals that are referenced in all of the subquery's window PARTITION BY
!  * clauses. This is permitted as window partitions are completely isolated
   * from each other and removing records from unneeded partitions early has
!  * no effect on the query results.
   */
  static void
  check_output_expressions(Query *subquery, bool *unsafeColumns)
