Date table / query and index measurement

I am creating a reliable date table to find out how best to contact it. The primary key cluster index will be included in the smart-date integer key key (according to the Kimball specification) with the name DateID. So far, I have been performing queries against it like this:

select Foo.orderdate -- a bunch of fields from Foo
      ,DTE.FiscalYearName
      ,DTE.FiscalPeriod
      ,DTE.FiscalYearPeriod
      ,DTE.FiscalYearWeekName
      ,DTE.FiscalWeekName  
      FROM SomeTable Foo
     INNER JOIN
       DateDatabase.dbo.MyDateTable DTE
     ON DTE.date = CAST(FLOOR(CAST(Foo.forderdate AS FLOAT)) AS DATETIME)

Keep in mind that Date is a nonclustered index field with values ​​such as: 2000-01-01 00: 00: 00.000

It just seemed to me that since I have a clustered integer index (DATEID), maybe I should convert the date and time into my database field so that it matches it and is associated with this field.

What do you think?

, , , ? ?

+1
1

, , :

select Foo.orderdate -- a bunch of fields from Foo 
  ,DTE.FiscalYearName 
  ,DTE.FiscalPeriod 
  ,DTE.FiscalYearPeriod 
  ,DTE.FiscalYearWeekName 
  ,DTE.FiscalWeekName   
  FROM SomeTable Foo 
 INNER JOIN 
   DateDatabase.dbo.MyDateTable DTE 
 ON Foo.forderdate >= DTE.date AND Foo.forderdate < DATEADD(dd, 1, DTE.date)

, , Foo DateID, , , .

, DateID, DateID - MyDateTable, ( ).

+1

Source: https://habr.com/ru/post/1523378/


All Articles