PHP 面试题 Mysql 索引
题目:
PRODUCT表(id,name,price,count)
- SQL code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->select * from PRODUCT where price=100
目前已经在price字段上加上了索引
1.不过以上查询速度还是很慢,请试说出慢的原因
2.请问如何优化才能加快速度
------解决方案--------------------
1、数据量大 加上limit 一定数量的限制
2、字段可以写出只要需要的字段 seletc id, name 等
3、主键和price一起做一个联合索引
剩下的楼下补充
------解决方案--------------------
select * from PRODUCT where price=100
就这些?加了索引还很慢的话就没道理了。索引就是非遍历查询,直接定位到price为100的地方!数据量大的话,查询上肯定要比不加要快很多!
难道你的数据库里有很多个price为100的数据?
------解决方案--------------------
------解决方案--------------------
也许price字段根本就不适合加索引,并不是所有字段都能加索引,有些加了反而更慢!
------解决方案--------------------
price中重复数据太多导致查询效率下降的可能 最大。
------解决方案--------------------
单就这个查询而言,
慢是因为它不是唯一索引;
如果数据量大,基本上没有太好办法优化! 或者可以给价格加一个区间联合索引,这样可以选查区间,后后再查100

Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

TheFiiOCP13cassetteplayerwasannouncedinJanuary.Now,FiiOisexpandingitsportfoliowithtwonewmodels-onewitharedfrontandonewithatransparentfront.Thelatternotonlyperfectlymatchestheretrocharmoftheangulardesign,butalso

The Klipsch Flexus Core 300 is the top model in the series and is positioned above the already available Flexus Core 200 in the company's soundbar line-up. According to Klipsch, this is the first soundbar in the world whose sound can be adapted to th

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

jquery隐藏select元素的方法:1、hide()方法,在HTML页面中引入jQuery库,可以使用不同选择器来隐藏select元素,ID选择器将selectId替换为你实际使用的select元素的ID;2、css()方法,使用ID选择器选择需要隐藏的select元素,使用css()方法将display属性设置为none,并将selectId替换为select元素的ID。

Shortly after Tesla launched the Model 3 Highland refresh towards the end of last year, the US federal EV tax incentive rules changed, cutting the potential discount in half for eligible buyers because of Tesla's use of Chinese LFP cells in the new M

因为select可以使开发者在同时等待多个文件缓冲区,可减少IO等待的时间,能够提高进程的IO效率。select()函数是IO多路复用的函数,允许程序监视多个文件描述符,等待所监视的一个或者多个文件描述符变为“准备好”的状态;所谓的”准备好“状态是指:文件描述符不再是阻塞状态,可以用于某类IO操作了,包括可读,可写,发生异常三种。select是一个计算机函数,位于头文件#include。该函数用于监视文件描述符的变化情况——读写或是异常。1.select函数介绍select函数是IO多路复用的函

More than a year after the launch of the Realme Pad 2 the manufacturer presents the more affordable Realme Pad 2 Lite. The new model is slightly smaller, as the display shrinks from 11.5 inches to 10.95 inches, with the IPS panel achieving a resoluti


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3汉化版
中文版,非常好用

记事本++7.3.1
好用且免费的代码编辑器

Dreamweaver Mac版
视觉化网页开发工具