惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - FallingAutumn

mysql常用命令集锦 Java ClassLoader加载机制理解 实际例子 Java ClassLoader加载机制理解 myeclipse 8.5破解方法 Replace Pioneer 试用推广 JAVA RMI调用实战学习 linux下关于压缩、解压相关的操作 关于hessian接口类方法顺序及对象序列化的实战研究 Java对象引用传递探索 Java异常学习总结 log4j配置详解 vs2005 sp1补丁安装,报1718错误: 数字签名拒绝 无法访问Windows Installer服务 之错误解决 打开word时,”无法注册这篇文档,不能创建从其他文档到这篇文档的链接“ 错误的解决 Oracle中DBMS_JOB.SUBMIT的用法说明 vs2008 sp1如何修复、删除以及增加组件的方法 OCI-22053: 溢出错误 的原因和解决方案 statspack的实战学习 - FallingAutumn - 博客园 ORACLE中,Schema的理解
mysql 语句or效率问题
FallingAutumn · 2013-07-05 · via 博客园 - FallingAutumn

今天看一同事代码中sql语句的拼接,看到where column=? or column=? .... 一直循环遍历下去,即根据传递进来的数组长度构造sql查询(mysql库)

for(int i= 0; i < len; i++)
        {
            sb.append("userjid=?");
            if(i != (len-1)){
                sb.append(" or ");
            }
        }

当时第一感觉是这样的SQL性能会有很大问题, 如果or拼接多到几十条时,肯定不乐观。 于是就自己进行了验证,结果让我大跌眼镜,多达400个的or查询拼接,在万条记录的表中,

耗时仅是毫秒级的... 我很无语,虽然userjid字段有索引,但也完全出乎我的意料,难道mysql库引擎对此做了优化,给改成in了?

且记录之,或待高人答疑。