JOIN 查询与多个查询

JOIN queries vs multiple queries(JOIN 查询与多个查询)

本文介绍了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 查询与多个查询

基础教程推荐