postgres=# explain select * from foo where 1 IN (1,2,3); QUERY PLAN ------------------------------------------------------------- Result (cost=0.00..35.50 rows=2550 width=4) One-Time Filter: (1 = ANY ('{1,2,3}'::integer[])) -> Seq Scan on foo (cost=0.00..35.50 rows=2550 width=4) (3 rows)
I would've expected that to be fully evaluated at plan-time, and optimized away.
That seems like an oversight. I guess that scenario doesn't happen very often in practice, but there's no reason not to do it when it does. Patch attached.
On a side-note, I find it a bit awkward that ScalarArrayOpExpr uses a 2-element List to hold the scalar and array arguments. Wouldn't it be much more straightforward to have explicit "Expr *scalararg" and "Expr *arrayarg" fields?
- Heikki
0001-Const-eval-ScalarArrayOpExprs.patch
Description: invalid/octet-stream
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers