SQL是否总是在加入后的位置,并且很快吗?

发布于 2025-02-12 01:06:56 字数 291 浏览 1 评论 0原文

说,我有两个大表格 - A和B。

我想从A中拿走3行,并将它们加入B:

select * from A join B
on A.externalKey = B.externalKey
where A.id in (1, 2, 3)

Will SQL(即PostgreSQL)的3行,认识到在加入之前应用的速度更快,因为条件取决于条件,仅在A的参数上?

如果否,是使用AS(从Where ...中选择 *)从Join B更快地选择 *的最佳方法?

Say, I have two big tables - A and B.

I want to take 3 rows from A and join them to 3 rows from B:

select * from A join B
on A.externalKey = B.externalKey
where A.id in (1, 2, 3)

Will SQL (namely, PostgreSQL) recognize that it's faster to apply WHERE before JOIN, because the condition depends only on A's parameters?

If no, is with A as (select * from A where ...) select * from A join B faster and the best way to do that?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文