“ left_joins”和“ left_joins”之间有什么区别?和“包含”在Rails 5中? [英] What's the difference between "left_joins" and "includes" in Rails 5?

查看:108
本文介绍了“ left_joins”和“ left_joins”之间有什么区别?和“包含”在Rails 5中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Rails 5中,他们添加了ActiveRecord查询方法 left_joins left_joins includes 有什么区别?我一直看到 includes 作为左联接。

In Rails 5, they have added the ActiveRecord query method left_joins. What's the difference between left_joins and includes? I've always seen includes as a left join.

推荐答案

includes 默认情况下会在2个查询中加载关联数据,就像 预加载
,但还有其他 引用 调用从使用两个单独的查询切换到创建单个 LEFT OUTER JOIN ,例如 left_joins

includes by default loads the association data in 2 queries just like preload. But with additional references call it switches from using two separate queries to creating a single LEFT OUTER JOIN like left_joins.

引用:

预载,热载,包含和加入

使ActiveRecord加入,包括,预加载和eager_load

这篇关于“ left_joins”和“ left_joins”之间有什么区别?和“包含”在Rails 5中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆