1. Table structure, time1 adds a common index:
CREATE TABLE `time_table` (
`time1` INT(11) NULL DEFAULT NULL,
`time2` INT(11) NULL DEFAULT NULL,
INDEX `time1` (`time1`)
)
ENGINE=MyISAM
;
2. Worm replication creates 2 million pieces of data
insert into time_table select * from time_table
3. Start query: time1 has index, time2 has no index, data 2 million
set profiling=1;
select * from time_table where time2=1111111;
select * from time_table where time1=1111111;
show profiles;
4. As a result, indexing slows down:
< H2 >400200time1=11111,time2=11111,200time1=22222,time2=22222,
200400time2=1time1()update time2=time1,
time1:
:
:
:
8001111112222
add indexed fields, but the query is slower.
my guess: the data is the same, the effect of the index is almost no, but because of the index, the field storage space is more, the query is slow, pure wishful thinking, hope to be able to answer one or two!
qq:2210170490