sql - Need to index column in AND statement? -


i have select on table this:

  • id
  • username
  • speed
  • is_running

the statement like:

select *    mytable   username = 'foo'     , is_running = 1 

i have index on "username". if i'm running above statement, need index "is_running" best performance? or first column of select make difference? i'm using mysql 5.0.

it depends on type of data you're storing. if it's bool, may not see gain index on column alone. may want try add composite index on 2 columns:

alter table mytable add index `idx_username_is_running` ( `username` , `is_running` ); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -