# 【www.2979.com】php 管理上百万条的数据库如何抓实管理查询速度_php手艺_脚本之家

16 1月 , 2020

1.对查询进行优化，应尽量防止全表扫描，首先应构思在 where 及 order by

where num is null

id from t where num=0 3.应尽量幸免在 where

4.应尽量制止在 where 子句中应用 or

from t where num=10 or num=20 能够那样查询： select id from t where
num=10 union all select id from t where num=20 5.in 和 not in

between 1 and 3 6.底下的询问也将引致全表扫描： select id from t where
name like ‘%abc%’ 若要升高功能，能够思谋全文字笔迹核实索。 7.假使在 where

select id from t where num=@num 能够改为勉强查询利用索引： select id
from t with where num=@num 8.应尽量防止在 where

select id from t where num/2=100 应改为: select id from t where
num=100*【www.2979.com】php 管理上百万条的数据库如何抓实管理查询速度_php手艺_脚本之家。2
9.应尽量防止在where子句中对字段实行函数操作，那将促成斯特林发动机放任使用索引而开展全表扫描。如：
select id from t where substring=’abc’–name以abc开端的id select id from
t where datediff(day,createdate,’二零零五-11-30’卡塔尔=0–‘2007-11-30’生成的id

createdate>=’二〇〇五-11-30′ and createdate
{"ft_lang_label":"__label__zh","ft_lang_prob":0.63608867,"math_prob":0.8336287,"size":1378,"snap":"2020-10-2020-16","text_gpt3_token_len":930,"char_repetition_ratio":0.26783115,"word_repetition_ratio":0.16774194,"special_character_ratio":0.23657474,"punctuation_ratio":0.07258064,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.970301,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-02T16:48:33Z\",\"WARC-Record-ID\":\"<urn:uuid:c4be61e7-9847-41b5-aec1-ed71e1d8dc1d>\",\"Content-Length\":\"23674\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:19708fa2-2cd7-4637-b73d-fe6a23542acf>\",\"WARC-Concurrent-To\":\"<urn:uuid:db54cb8a-2d92-427e-8ff3-b6eeb9f9f782>\",\"WARC-IP-Address\":\"154.195.220.131\",\"WARC-Target-URI\":\"https://www.qyban.com/archives/1451.html\",\"WARC-Payload-Digest\":\"sha1:PTEGSV3LBQFG64SYPIL3KWVQH47H6CMM\",\"WARC-Block-Digest\":\"sha1:KEFLOF7B6A6YEBBUBUYURY3CZBRZC6KA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370506988.10_warc_CC-MAIN-20200402143006-20200402173006-00536.warc.gz\"}"}