use pconnect and remove redundant query condition