Indexing on DateTime and VARCHAR fields in SQL Server 2000, which one is more effectient? -
we have calllog table in microsoft sql server 2000. table contains callendtime field type datetime
, , it's index column.
we delete free-charge calls , generate monthly fee statistics report , call detail record report, sqls use callendtime
query condition in where
clause. due lot of records exist in calllog table, queries slow, want optimize starting indexing.
question
will more effictient if query upon indexed varchar
column callenddate ? such as
-- datetime based query select count(*) calllog callendtime between '2011-06-01 00:00:00' , '2011-06-30 23:59:59' -- varchar based queries select count(*) calllog callenddate between '2011-06-01' , '2011-06-30' select count(*) calllog callenddate '2011-06%' select count(*) calllog callendmonth = '2011-06'
it has datetime. dates stored number in database relatively quick see if value between 2 numbers.
if you, i'd consider splitting data on multiple tables (by month, year of whatever) , creating view combine data tables. way, functionality needs entire data set can use view , needs months worth of data can access specific table lot quicker contain less data.
Comments
Post a Comment