Okay now let me give an example
date : 15.12.2012 00:16:39
Now this will be stored as
20121215001639
Now for example if i want to retrieve rows older than 30 min (30*60=1800 sec)
I can do just as
where date<20121215001639+1800
So would this be a performance way instead of storing as date time ?
I fully agree with marc_s’s comment above, but I decided to make a test, just for fun.
I created two tables, one with a
datetimecolumn and one with abigintcolumn, representing the same data.Here is the sql fiddle: http://www.sqlfiddle.com/#!3/74976/3
I’ve run this query for 500, 1000 and 5000 records and every time noticed that the execution plans are identical, so from a performance point of view there’s no gain in using
bigint.However, there are obvious downsides for the
bigintapproach; some of them:bigintrequires more code to be written