Hi,
I want to find the earliest and latest times in the time column of my table
internet_usage:
+--------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------------------+------+-----+---------+-------+
| uid | int(10) unsigned | | MUL | 0 | |
| time | timestamp(14) | YES | | NULL | |
| ip | int(10) unsigned | | | 0 | |
| urlid | int(10) unsigned | | | 0 | |
| timetaken | smallint(5) unsigned | YES | | 0 | |
| cs_size | int(10) unsigned | YES | | 0 | |
| sc_size | int(10) unsigned | YES | | 0 | |
| method_ID | tinyint(3) unsigned | | | 0 | |
| action_ID | tinyint(3) unsigned | | | 0 | |
| virus_ID | tinyint(3) unsigned | | | 0 | |
| useragent_ID | smallint(5) unsigned | | | 0 | |
+--------------+----------------------+------+-----+---------+-------+
So far there are 324936160 rows. If I do :
SELECT MIN(time) as earliest, MAX(time) as latest
from internet_usage;
I can see the query is going to run for a long time. Do I have to create an
index on time to speed this up or is there another way of doing it?
Thanks for any help.
JS.
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger