Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Quote:
|
If you're using any sort of time stamp, it wouldn't make sense because no two entries would share the same date.
|
Exactly. Usually, a timestamp store the time with a millisecond precision.
Putting those in a separate table with FK referencing them will add nothing but overhead.
Your "time" table will grow, and each time you will need to look up for that time, you will have to scan the indexes.
And a simple reminder: the more datas a table contains, the more time the indexes needs to be parsed. It can reache a state where a sequential read is faster than an index scan.
http://www.mysqlperformanceblog.com/...-where-column/
Quote:
The reason why index scan is slower than table scan is that in case of the index scan the MySQL needs to perform more operations like :
read index, get pointer to row, get data from row,
that adds overhead to the operations.
In case of table scan MySQL just goes trough the table and read all rows in continuous mode.
When count of scanned rows more than 20% (in our example) the overhead of index scan makes it non-effective.
In real queries the right percent of rows depends on many factors, but for random uniformly distributed values I would say it is in 20-30% interval.
|
It should not be the case if you normlalize your dates, because no entries would be similar, but still, many peoples don't realize that.
I learned it not so long ago myself.
In the case of a timestamp, I almost always find it to be relative to the information I write in my table, so I keep them together.
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 04-29-2008 at 12:40 PM..
|