I have several tables that must be joined based on start and stop dates, for instance ...
SELECT * FROM [t1] JOIN [t2] ON [t2].[start] BETWEEN [t1].[start] AND [t1].[stop] OR [t2].[stop] BETWEEN [t1].[start] AND [t1].[stop] OR [t2].[start] < [t1].[start] and [t2].[stop] > [t1].[stop] These tables could be in the multiple-millions of rows.
I have the option to store the start/stop as datetime2 and/or bigint(nanoseconds since epoch). Given this option - would there be a performance gain by using the bigint if indexed?
Any pros/cons with either approach?
I would expect the integer approach to be faster -
ON [t2].[start] <= [t1].[stop] AND [t2].[start] <= [t1].[stop][t2].[start] <= [t1].[stop] AND [t1].[start] <= [t2].[stop]