I have the below query running and it is taking forever. I'm not quite sure why as my other queries run with reasonable speed, so I cannot assume it is a network issue. [LAST_NAME] & [EMPLOYEE_NUMBER] are indexed. Any tips on speeding up this query? The table does have 945k records in it and is housed in a back end DB. I realize that is a lot of records, but this seems to be running abnormally slow. Here is why I ask...I have a form that provides a search function which is based on this query. The query is not called upon until the user needs to search for an employee. However, for some reason unknown to me the query runs every time the form is opened
. I DO NOT have the query running at the open/load of the form. The only time the query is to run is when the user clicks on a search button. Can anyone explain why the query runs on start-up anyway? Any way to fix/work around this? Thanks in advance!
Code:
SELECT tblSearchSource.LAST_NAME, tblSearchSource.FIRST_NAME, tblSearchSource.EMPLOYEE_NUMBER, tblSearchSource.STORE, [FIRST_NAME] & " " & [LAST_NAME] & " " & [EMPLOYEE_NUMBER] & " " & [STORE] AS Searchable, StrConv([FIRST_NAME],3) & " " & StrConv([LAST_NAME],3) & ", Store # " & [STORE] AS Employee
FROM tblSearchSource
GROUP BY tblSearchSource.LAST_NAME, tblSearchSource.FIRST_NAME, tblSearchSource.EMPLOYEE_NUMBER, tblSearchSource.STORE
ORDER BY tblSearchSource.LAST_NAME;