I have an events log database. I need to limit the size of SQL searches when looking for a specific EventID. This is for performance purpose.
Does the following query limits the SQL Query?
SELECT EventID FROM
(SELECT TOP 100000 EventID,EventName FROM Events ORDER BY EventTime DESC) T
WHERE EventName = 'Whatever'
Rather than doing the following
SELECT EventID FROM Events WHERE EventName = 'Whatever'
Thanks
Query 1 will locate top 100.000 events by Event time, then filter those records by EventName = ‘Whatever’ – the result will be <= 100.000 events.
Query 2 will locate all events where EventName = ‘Whatever’
I can only guess you’re trying to achieve the following: