It seems the optimizer will automatically merge the filter conditions to the subquery (please see the following query plan). As the subquery is more readable, i will use it.

* The query plan using subquery.

```
testdb-#     SELECT text_svec, set_list, tot_products
testdb-#     FROM (
testdb(#         SELECT madlib.svec_to_string(set_list) as text_svec,
testdb(#                set_list,
testdb(#                tot_products
testdb(#         FROM (
testdb(#             SELECT
testdb(#                 madlib.svec_minus(madlib.svec_plus(a.set_list, b.set_list), madlib.svec_mult(a.set_list, b.set_list)) as set_list,
testdb(#                 madlib.svec_l1norm(madlib.svec_minus(madlib.svec_plus(a.set_list, b.set_list), madlib.svec_mult(a.set_list, b.set_list))) as tot_products
testdb(#             FROM
testdb(#                 assoc_rule_sets a 
testdb(#            CROSS JOIN
testdb(#                 assoc_rule_sets b
testdb(#            WHERE
testdb(#               a.text_svec <> b.text_svec
testdb(#               AND a.iteration = 3 
testdb(#               AND b.iteration = 3
testdb(#         ) t1
testdb(#         WHERE madlib.svec_l1norm(set_list)= 4  
testdb(#     ) t2
testdb-#     GROUP BY 1, 2, 3
testdb-#     DISTRIBUTED BY (text_svec);
                                                                                                      QUERY PLAN                                                                                                       
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Redistribute Motion 1:4  (slice3; segments: 1)  (cost=8.41..8.48 rows=1 width=72)
   Hash Key: text_svec
   Rows out:  Avg 108.5 rows x 4 workers at destination.  Max 121 rows (seg1) with 78 ms to first row, 80 ms to end, start offset by 52 ms.
   ->  GroupAggregate  (cost=8.41..8.48 rows=1 width=72)
         Group By: "?column3?", "?column4?", "?column5?"
         Rows out:  434 rows with 85 ms to first row, 87 ms to end, start offset by 44 ms.
         ->  Sort  (cost=8.41..8.41 rows=4 width=64)
               Sort Key: "?column3?", "?column4?", "?column5?"
               Rows out:  2608 rows with 85 ms to end, start offset by 44 ms.
               Executor memory:  4169K bytes.
               Work_mem used:  4169K bytes.
               ->  Gather Motion 4:1  (slice2; segments: 4)  (cost=4.02..8.38 rows=1 width=64)
                     Rows out:  2608 rows at destination with 1.948 ms to first row, 63 ms to end, start offset by 45 ms.
                     ->  Nested Loop  (cost=4.02..8.21 rows=1 width=64)
                           Join Filter: madlib.svec_l1norm(madlib.svec_minus(madlib.svec_plus(a.set_list, b.set_list), madlib.svec_mult(a.set_list, b.set_list))) = 4::double precision AND a.text_svec <> b.text_svec
                           Rows out:  Avg 652.0 rows x 4 workers.  Max 1051 rows (seg2) with 0.670 ms to first row, 66 ms to end, start offset by 43 ms.
                           ->  Seq Scan on assoc_rule_sets a  (cost=0.00..3.96 rows=1 width=64)
                                 Filter: iteration = 3
                                 Rows out:  Avg 33.8 rows x 4 workers.  Max 55 rows (seg2) with 0.207 ms to first row, 0.279 ms to end, start offset by 43 ms.
                           ->  Materialize  (cost=4.02..4.06 rows=1 width=64)
                                 Rows out:  Avg 4556.2 rows x 4 workers.  Max 7425 rows (seg2) with 0.059 ms to first row, 2.223 ms to end of 55 scans, start offset by 112 ms.
                                 ->  Broadcast Motion 4:4  (slice1; segments: 4)  (cost=0.00..4.01 rows=1 width=64)
                                       Rows out:  Avg 135.0 rows x 4 workers at destination.  Max 135 rows (seg0) with 0.742 ms to first row, 2.098 ms to end, start offset by 42 ms.
                                       ->  Seq Scan on assoc_rule_sets b  (cost=0.00..3.96 rows=1 width=64)
                                             Filter: iteration = 3
                                             Rows out:  Avg 33.8 rows x 4 workers.  Max 55 rows (seg2) with 0.171 ms to first row, 0.220 ms to end, start offset by 44 ms.
 Slice statistics:
   (slice0)    Executor memory: 345K bytes avg x 4 workers, 345K bytes max (seg0).
   (slice1)    Executor memory: 441K bytes avg x 4 workers, 441K bytes max (seg0).
   (slice2)    Executor memory: 359K bytes avg x 4 workers, 381K bytes max (seg1).
   (slice3)    Executor memory: 4581K bytes (seg0).  Work_mem: 4169K bytes max.
 Statement statistics:
   Memory used: 128000K bytes
 Total runtime: 133.371 ms
(34 rows)

```