mysql_fdw icon indicating copy to clipboard operation
mysql_fdw copied to clipboard

[Feature Support] Support ANY ARRAY

Open khieuvm opened this issue 2 years ago • 0 comments

We have already implemented this feature:

Support case:

  • With operators: =, <> and right operand is ANY (ARRAY) and field in right operand of ANY (ARRAY) are const, array expression, using IN clause instead of ANY ARRAY
  • Other cases with operator is >, <, <=, >=, and field in right operand of ANY (ARRAY) are const, expression can push down but need to change another query, using AND/OR instead of ANY ARRAY

Unsupported cases:

  • With operators are different from operator =, <> and other fields in right operand of ANY (ARRAY) like subquery, ... so now I do not push down, Postgres core will handle ANY ARRAY
  • With operators are operator =, <> and other fields in right operand of ANY (ARRAY) like subquery, ... so now we use FIND_IN_SET instead of ANY ARRAY

Example:

EXPLAIN (VERBOSE, COSTS OFF)
  SELECT * FROM ft1 t1 WHERE c1 <= ANY(ARRAY[1, 2, 3]);
                                                                        QUERY PLAN                                                                        
----------------------------------------------------------------------------------------------------------------------------------------------------------
 Foreign Scan on public.ft1 t1
   Output: c1, c2, c3, c4, c5, c6, c7, c8
   Local server startup cost: 10
   Remote query: SELECT `c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM `mysql_fdw_post`.`position_data1` WHERE (`c1` <= 1 OR `c1` <= 2 OR `c1` <= 3)
(4 rows)

I would like to contribute them to the repository and community. I will create a pull request to share this feature if you have any interest.

khieuvm avatar Mar 29 '22 11:03 khieuvm