-- 问题1 tablename使用主键索引反而比idx_ref_id慢的原因EXPLAIN SELECT SQL_NO_CACHE COUNT(id) FROM dbname.tbname FORCE INDEX (idx_ref_id)EXPLAIN SELECT SQL_NO_CACHE COUNT(id) FROM dbname.tbname FORCE INDEX (PRIMARY) 原因:可以看到走主键索引的时候效率比较差.那么是为什么呢.平时我们检索一列的时候,基本上等值或范围查询
在执行一个简单的sql查询,表中数据量为14万 sql语句为:SELECT id,titile,published_at from spider_36kr_record where is_analyze=0 ORDER BY create_time DESC LIMIT 10;开始的时候很快,但后面sql语句查询越来越慢 .开始查找问题原因:1. 执行explain 发现没毛病,正常走了索引 2. 执行SHOW PROFILES 查出Query_ID后在执行 show profile for q
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE tbl_name [FIELDS [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char' ] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string