we access the WMS service by sending a request having a ogc:Filter. The Geoserver interprets the filter and creates SQL likes:
There are case where we have to wait 20 sec. for postgres to respond. With the "gid" IS NOT NULL part out the Query is 2 sec long.
Below is the SLD we send.