如果操作(查询)涉及的表数量增加,是否会影响性能?

发布于 2024-10-20 01:02:10 字数 51 浏览 1 评论 0原文

对数据库执行的操作数量会降低性能。但是任何查询中涉及的表数量(例如表的连接)会降低性能?

The number of operations performed on database degrade the performance.But the number of tables involved in any query (for example joining of tables) reduce the performance ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心如荒岛 2024-10-27 01:02:10

未必。性能由索引、内部存储结构和查询计划等因素决定。性能和查询涉及的表数量之间没有直接关联。

Not necessarily. Performance is determined by indexes, internal storage structures and query plans among other things. There is no direct correlation between performance and the number of tables involved in a query.

御弟哥哥 2024-10-27 01:02:10

根据经验,数据库操作中涉及的表的数量并不能说明该操作的性能。考虑在多个表上进行主键查找与完全扫描一张大表。

根据经验,向特定数据库操作添加附加表通常会导致可测量的性能下降。通过可衡量,我的意思是数据库将为您提供一个数字来描述两个查询的性能,而第二个查询的数字会更差。如果差异明显,那就是另一个问题了。再次考虑在连接中添加 10 个主键查找,而不是添加一个 90 亿行的表来进行全面扫描。

作为经验法则,不要相信经验法则。例如,如果附加表是内连接且为空,或者包含少量行,或者启用更有效的访问路径(小表的笛卡尔连接以便能够在大表上使用索引),则上述规则是错误的,或……或……或……

As a rule of thumb, the nr of tables involved in a database operation says nothing about the performance of that operation. Think primary key lookups on several tables vs full scanning one big table.

As a rule of thumb, adding an additional table to a specific database operation will in general result in a measurable performance degradation. By measurable, I mean that the database will provide you with a number to describe the performance of both queries and the number for the second query will be worse. If the difference is noticable at all, is another question. Again, think adding 10 more primary key lookups to a join, versus adding one more 9 billion row table to fully scan.

As a rule of thumb, don't trust rules of thumbs. For example, the above rules are wrong if the additional table is inner joined and empty, or contains a small nr of rows, or enables a more efficient access path (cartesian joins of small tables to be able to use index on big table), or ... or .... or..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文