JOIN queries vs multiple queries(JOIN 查询与多个查询)
问题描述
JOIN 查询是否比多个查询更快?(您运行主查询,然后根据主查询的结果运行许多其他 SELECT)
Are JOIN queries faster than several queries? (You run your main query, and then you run many other SELECTs based on the results from your main query)
我这么问是因为加入它们会使我的应用程序的设计复杂化
I'm asking because JOINing them would complicate A LOT the design of my application
如果它们更快,有人能粗略估计大约多少吗?如果是 1.5 倍我不在乎,但如果是 10 倍我想我会.
If they are faster, can anyone approximate very roughly by how much? If it's 1.5x I don't care, but if it's 10x I guess I do.
推荐答案
这太模糊了,无法为您提供与您的具体案例相关的答案.这取决于很多事情.Jeff Atwood(本网站的创始人)实际上 写道这个.不过,在大多数情况下,如果您拥有正确的索引并且正确执行 JOIN,那么执行 1 次行程通常比执行多次行程要快.
This is way too vague to give you an answer relevant to your specific case. It depends on a lot of things. Jeff Atwood (founder of this site) actually wrote about this. For the most part, though, if you have the right indexes and you properly do your JOINs it is usually going to be faster to do 1 trip than several.
这篇关于JOIN 查询与多个查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JOIN 查询与多个查询
基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01