* Sebastian Bergmann > Roger Baklund wrote: > > You can almost always improve the performance of queries by adding an > > index. The trick is to add the right index... :) If you for instance > > often did a "SELECT * FROM pot_accesslog WHERE client_id=$id AND > > timestamp > NOW() - INTERVAL 24 HOUR", you could add an index with > > the involved fields: KEY client_time (client_id,timestamp). > > Would this perform different from a situation where I have separate > indexes on both columns?
Yes. Using client_id only or timestamp only the server would need to do a full scan for all timestamps for that client or all clients for the timespan represented by the timestamp condition (24 hours). It can not use multiple indexes in the same statement (except for when using joins). The combined index would be able to select the wanted records directly, and it may also be used for any other query using the client_id, so you will not need KEY client_id (client_id). -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php