Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    Unanswered: Do I need 'index' on all columns in WHERE clause

    I have index on key_logId, do I need to have an index on log_actionPerformed too?

    SELECT log_dateTime, log_actionPerformed FROM log_trips WHERE key_logId = 5 AND log_actionPerformed LIKE 'note%' ORDER BY key_logId;

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    not necesarily, but it couldn't hurt to try

    mysql will use only one index for each SELECT

    do an EXPLAIN on your query, add the second index, then do another EXPLAIN

    see if there's any difference | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts