I acutally ended up rewriting the query and its much faster. Dynamic SQl was much faster but coz of SQL injection attack, eneded of rewritng the query. Lowell, thanks for your help and if you don't mind can you please remove the index information as I am afraid that is proprietary info.