Optimizing MySQL Query
Posted: Wed Jul 10, 2002 2:45 am
I have a batch script that runs a series of queries and creates a report. As the database grows the batch file is taking longer and longer to complete. My queries are very simple but I'm wondering if there is some way to optimize them. The table contains Windows NT security log data. It grows larger every night as new data is imported.
The result of an explain query of the above query is as follows.
table = sec
type = ref
possible_keys = eventid,computer,eventid_eventdate
key = computer
key_len = 16
ref = const
rows = 1
Extra = where used
Can anyone tell me how to get more mileage out of this? Is there a way to force MySQL to use a specific index?
Paul
Code: Select all
select eventid, eventtime, userid, description from logdb.sec where eventid="529" and computer="server1" and (to_DAYS(current_date)-to_DAYS(eventdate))=1;table = sec
type = ref
possible_keys = eventid,computer,eventid_eventdate
key = computer
key_len = 16
ref = const
rows = 1
Extra = where used
Can anyone tell me how to get more mileage out of this? Is there a way to force MySQL to use a specific index?
Paul