I have a table with a large number of columns. Searching in the box at the top of the table takes longer than expected (a minute or more). I traced to see what's going on and it appears that every column in the table is search for the value put into the search box (not just those designated in the "Search Fields" tab).
There are 17 columns in the table. Only six of the columns are selected as the "Search Fields".
One of the columns in "Search Fields" has a label that contains the month name and year. So I search for 'Jul 2019' and the trace shows these params in the query:
@P0M=N'%Jul%'
, @P1M=N'%Jul%'
, @P2M=N'%Jul%'
, @P3M=N'%Jul%'
, @P4M=N'%Jul%'
, @P5M=N'%Jul%'
, @P6M=N'%Jul%'
, @P7M=N'%Jul%'
, @P8M=N'%Jul%'
, @P9M=N'%Jul%'
, @P10M=N'%Jul%'
, @P11M=N'%Jul%'
, @P12M=N'%Jul%'
, @P13M=N'%2019%'
, @P14M=N'%2019%'
, @P15M=N'%2019%'
, @P16M=N'%2019%'
, @P17M=N'%2019%'
, @P18M=N'%2019%'
, @P19M=N'%2019%'
, @P20M=N'%2019%'
, @P21M=N'%2019%'
, @P22M=N'%2019%'
, @P23M=N'%2019%'
, @P24M=N'%2019%'
, @P25M=N'%2019%'
, @P26M=N'%2019%'
, @P27M=N'%2019%'
, @P28M=N'%2019%'
, @P29M=N'%2019%'
The WHERE clause has many OR statements with nested queries inside. Like this:
OR(
SELECT ISNULL(CONVERT(VARCHAR(255), P.columnname), '')
FROM dbo.table1 P
WHERE P.columnname=T.columnname
AND P.columnname=T.columnname
) LIKE @P4M
It looks like every column is compared to both search terms 'Jul' and '2019'.
Is this the expected search behavior or is there something I can do to limit the searched columns (other than selecting them in "Search Fields")?
Thanks