求教版主一个PHP性能有关问题,小弟我是个爱学习的孩子

WBOY
Release: 2016-06-13 12:27:17
Original
825 people have browsed it

求教版主一个PHP性能问题,我是个爱学习的孩子.在线等
是这样
MYSQL中  某个表中   最多可能有  2万条记录左右的数据量
前台一个模糊查询功能 like  对这2万条查询

我百度了一下,说是like速度很慢...说什么没有索引 就会对全表查询
那么做为新手的我,想听高手们指导一下,.怎么可以让查询更快一些呢.
因为我的这个SQL语句比较复杂..要检索三个字段
如下:

$sql="select 字段1,字段2 from `baikequanshu` where `class` = 1 && (`baike_key` LIKE '%".$content."%' || `biaoti` LIKE '%".$content."%' || `neirong` LIKE '%".$content."%') order by tj desc,id desc limit 0,30";
$query=mysql_query($sql);

也就是说 要对 baike 字段检索外  还要对 标题  内容(内容中不会有太多文字)  进行检索..然后还要用order by排序

我百度一下说. Like 很慢...那么当达到2万条数据 有没有什么好方法   让速度更快呢?
还有就是 字段索引是怎么回事啊?

求解决方法啊...在线等
------解决思路----------------------
2万条记录,加索引,用like不会慢的,除非你的服务器是小霸王

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!