The web GUI creates pages for the grid result. The query for the row count uses hardcoded values e.g.
select count(1) as tsf_rowcounter
from [table] as t1
where (t1.[col1] = 50 and t1.[col2] = 145 and t1.[col3] = 17340)
We have an issue where this specific query is sometimes slow with an execution time of 50 minutes or more and the paged query is fast (within seconds).
Please change the row count query to use parameters instead of hardcoded values. With this change we are able to attach a fixed query plan to have an consistent query performance. Also the number of compiled queries are reduces with this change