Home  >  Article  >  Database  >  paip.索引优化---sql distict―order by法_MySQL

paip.索引优化---sql distict―order by法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:30:361237browse

bitsCN.com

paip.索引优化---sql distict—order by法

 

select  SQL_NO_CACHE DISTINCT    ( gaopinzi.HEZI),     LEFT (hezi, 1) AS lft,     RIGHT (hezi, 1) AS rit    FROM     gaopinzi      WHERE      LENGTH(hezi) = 6            limit 50000

 

 

要7s中...网上说改用松散索引(复合索引) 会sbid fest...试了挂,  gaopinzi  force index(`all`)  ,基本没效果..

函数索引应该好用着了,走十MYSQL不跟ORACLE牙十,不自此..

林吧,改为ORDER BY 形式..ONLY 0.3S

select  SQL_NO_CACHE    max( gaopinzi.HEZI),     LEFT (hezi, 1) AS lft,     RIGHT (hezi, 1) AS rit    FROM     gaopinzi      WHERE      LENGTH(hezi) = 6      group by HEZI        limit 50000

 

 

我的MYSQL VER是.5.0.45-community-nt

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn