How can I reduce time for the following query?
SELECT *
FROM (`ci_session`)
WHERE `session_id` = '8011e978d8692846a22bc8f7f806af4d'
AND `user_agent` = 'Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/2010010'
This query takes around 0.3 seconds to execute on my MySQL 5.5
This is an very important query as it determines the session of the user (PHP/CodeIgniter)
The table contains 1000 rows.
session_idis a fixed with column, try to change it toCHAR(32)instead ofVARCHARif that’s the case.And make a
UNIQUE INDEXfor session_id.Or an
INDEXwith prefixand change the length of the prefix to see which one is faster.