I am writing a program that sends an email at a specific time for a client. I have a .NET method that takes time zone, time zone and destination time and returns time in this time zone. Therefore, my method is to select each individual time zone in the database, check the correct time using the method, and then select each client from the database with this time zone.
The request will look like one of them. Keep in mind that the order of the result set does not matter, so the union will be in order. Which is faster or do they really do the same?
SELECT email FROM tClient WHERE timezoneID in (1, 4, 9)
or
SELECT email FROM tClient WHERE timezoneID = 1 UNION ALL SELECT email FROM tClient WHERE timezoneID = 4 UNION ALL SELECT email FROM tCLIENT WHERE timezoneID = 9
Edit: timezoneID is the foreign key for tTimezone, the table with the timezoneID with the primary key, and the time zone name is varchar (20). In addition, I went with WHERE IN , since I did not want to open the analyzer.
Edit 2: Request processes for 200k rows in less than 100 ms, so at this point I am done.
Shawn source share