I have a table MyTable with several columns with the following data types:
Date datetimeoffset
Column0 varchar(20)
Column1 float
Column2 float
Column3 int
I run the following query:
SELECT Date, Column1
FROM
dbo.MyTable
WHERE Date BETWEEN '2023-06-01 00:00:00' AND '2023-06-10 00:00:00'
AND Column0 = 'value0'
I would like to speed up the query.
I heard about some indices. Should I change the type of Column0 to uniqueidentifier to speed up the query instead varchar? Initially, I thought varchar is smaller than uniqueidentifier. In my table Column0 has 6 different values.
I assume that if instead of varchar in the table an uniqueidentifier is introduced and when executing the mentioned query an ancillary table with my six values used via JOIN, will it be faster?
What if there are several similar tables with common columns, e.g. Date and Column0?