Optimizing queries with Expensive UDF Predicates