473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Indexing Date/Time fields.

If we have a date/time field and are doing frequent queries
WHERE {date/time field} BETWEEN TimeA AND TimeB

Does it make sense, query speed wise, to create an index on the date/time
field?

The reason I ask is that TimeA and TimeB are significant down to seconds.
My *assumption* is that with a large amount of data scatter very few records
will contain duplicate date/time points. And that under these circumstances,
indexing will be of little value since every date/time point will need to be
examined in detail. Date/time fields are actually floating point numbers
after all.

In other words, the assumption I am making is that if most of the data in a
field is unique, then indexing will yield little or no query performance
benefit.

Is my "assumption" valid?
Would an index on the date/time field speed up this type of query?

Thomas Bartkus
Jul 23 '05 #1
1 4801
"Thomas Bartkus" <to*@dtsam.com> wrote in message
news:5a********************@telcove.net...
If we have a date/time field and are doing frequent queries
WHERE {date/time field} BETWEEN TimeA AND TimeB

Does it make sense, query speed wise, to create an index on the date/time
field?

The reason I ask is that TimeA and TimeB are significant down to seconds.
My *assumption* is that with a large amount of data scatter very few records will contain duplicate date/time points. And that under these circumstances, indexing will be of little value since every date/time point will need to be examined in detail. Date/time fields are actually floating point numbers
after all.

In other words, the assumption I am making is that if most of the data in a field is unique, then indexing will yield little or no query performance
benefit.

Is my "assumption" valid?
Would an index on the date/time field speed up this type of query?


Okay. I'll answer my own question just in case anyone is interested.

I ran a few tests and my assumption was *wrong*.

Indexing on a field that contains mostly or entirely discrete values helps
the query speed substantially. Indexing on date/time fields or floating
point fields with lots of data scatter does speed up queries involving those
fields in a WHERE clause restriction.

This was a surprise to me!
Thomas Bartkus


Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
9
by: noone | last post by:
I have a database file that I use an autonumber field as the primary key index. Because of some rearrangements in the past, this index does not match the order that I would like it to be in, that...
2
by: rivka.howley | last post by:
I wrote some code that creates a table with a date/time field at 15-minute intervals. Here's how I create and populate the table With tblDataTemp ..Fields.Append .CreateField("CT_ID", dbLong)...
9
by: John Sidney-Woollett | last post by:
Hi I'm building a web app where changes to customer orders are logged in the following table, and I worried about the time that it will take to locate records that need further...
6
by: Hennie7863 | last post by:
Hi everybody, After days reading stuff about indexing, extents, pages, 8KB, 64 KB, IGNORE_DUP_KEY, CREATE INDEX, bla bla, lalalala, lllllll, grrrrrrr and testing with different kinds of queries,...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
1
by: brino | last post by:
hi all ! i have 2 fields in a form - a Date field & a Time field. these 2 fields have to be combined into the one field which has date & time. i know there must be some code to do this. i have...
0
by: rclark30 | last post by:
Hello to everyone out there. I am a non SQL person TRAPPED in a nightmare! The long short is we have a CRM 3.0 database that is running in SQL 2005 on a Windows 2003 SP1 Server. (HP ProLiant ML350...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.