Implement query timeout and minimal user defined function.