In a table where there is a TimeStamp type field that is used, for example, among other things, to know the sum of all the records of a particular date, that is, by doing:
select sum(campo_valor) from tabla where cast(campo_fecha as date)='2016-06-15'
Is it better to use two fields one Date and another Time or cast is still the best option?.
Since I have noticed that my queries with cast can not be indexed (or maybe I am doing something wrong), I have tried with all the possible combinations of the fields of that table and the only way that my query is indexed and be faster for more than 1 second is using something like this:
select (sum(campo_valor) from tabla where campo_fecha>='2016-06-15 00:00:00' and campo_fecha<=2016-06-15 23:59:59