Wednesday 25 April 2012

How indexing impact on mysql table

############# BEFORE INDEXING ON datetime field ################
Total Records ared: 3299
EXPLAIN SELECT * FROM  `order_request_details` WHERE DATE(  `created_at` ) =  '2012-04-24'
5 Record found out of 3299
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    3372    Using where

EXPLAIN SELECT * FROM  `order_request_details` WHERE  `created_at` =  '2012-04-24'
No result
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    3136    Using where

EXPLAIN SELECT * FROM  `order_request_details` WHERE  `created_at` BETWEEN '2012-04-24' AND '2012-04-24';
No result
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    3533    Using where

EXPLAIN SELECT * FROM  `order_request_details` WHERE  `created_at` >= '2012-04-24:00:00:00' AND  `created_at` <= '2012-04-24:23:23:59';
5 Record found out of 3299
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    3237    Using where


############# AFTER INDEXING ON datetime field ################

EXPLAIN SELECT * FROM  `order_request_details` WHERE DATE(  `created_at` ) =  '2012-04-24'
5 Record found out of 3299
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    3327     Using where


EXPLAIN SELECT * FROM  `order_request_details` WHERE  `created_at` >= '2012-04-24:00:00:00' AND  `created_at` <= '2012-04-24:23:23:59';
5 Record found out of 3299
id    select_type    table    type    possible_keys    key    key_len    ref    rows    Extra
1    SIMPLE    order_request_details    ALL    NULL    NULL    NULL    NULL    5    Using where

No comments:

Post a Comment