Understanding Explain?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce D

    #1

    Understanding Explain?

    I'm trying to understand MySQL better. I can't seem to figure out why the
    second query takes 2 minutes and the first query takes 12 seconds. It
    should be noted that the table, KBM, has 250 million records. I'm using
    MySQL 5.0.2.
    I guess I'm trying to get a better understanding of what "using index" means
    in the "extra" column.

    Here's the result of the explain on my first query:
    SQL-query: explain Select count(1) as counter from kbm force index
    (NewEstimatedIn come,State) where 1=1 and ( (State = 'OH') )

    id select_type table type possible_keys key key_len ref rows Extra
    1 SIMPLE kbm ref State,NewEstima tedIncome State 2 const 7958721 Using where,
    Using index


    Here's the result of the explain on my second query:
    SQL-query: explain Select count(1) as counter from kbm force index
    (NewEstimatedIn come,State) where 1=1 and ( (State = 'OH') ) and (
    (NewEstimatedIn come >= '030' and NewEstimatedInc ome <= '039') );

    id select_type table type possible_keys key key_len ref rows Extra
    1 SIMPLE kbm ref State,NewEstima tedIncome State 2 const 7958721 Using where

    Any information is appreciated.
    Anywhere I can read more about this stuff...besides mysql.com?

    TIA
    -bruce duncan



Working...