当前位置:网站首页>ThinkPHP Association preload with
ThinkPHP Association preload with
2022-07-07 05:16:00 【Azure is waiting for you】
Pre query loading function of associated query , Mainly solved N+1 The problem of this query , Improve performance .
$list = User::select([1,2,3]);
foreach($list as $user){
// Get the information associated with the user profile model data
dump($user->profile);
}
The above code will execute 4 Queries
Use associative preloading
$list = User::with(['profile'])->select([1,2,3]);
foreach($list as $user){
// Get the information associated with the user profile model data
dump($user->profile);
}
If you use the associated pre query function , It can become 2 Queries ( For one-to-one relationships , If you use withJoin Only one query ), Improve performance .
$list = User::with(['profile'])->select([1,2,3]);
foreach($list as $user){
// Get the information associated with the user profile model data
dump($user->profile);
}
Mainly because with Query changed to in Conditions of the query , Found out at one time 3 strip profile model data
perform sql as follows
边栏推荐
- SQL injection - secondary injection and multi statement injection
- 《四》表单
- Error: No named parameter with the name ‘foregroundColor‘
- 谈谈讲清楚这件事的重要性
- sublime使用技巧
- Auto. JS get all app names of mobile phones
- Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
- Auto.js 获取手机所有app名字
- Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.
- QT simple layout box model with spring
猜你喜欢
一文搞懂常见的网络I/O模型
torch optimizer小解析
Ansible overview and module explanation (you just passed today, but yesterday came to your face)
pmp真的有用吗?
PMP证书有没有必要续期?
Is it necessary to renew the PMP certificate?
全链路压测:影子库与影子表之争
[email protected] Mapping relatio"/>
Why JSON is used for calls between interfaces, how fastjson is assigned, fastjson 1.2 [email protected] Mapping relatio
SQL injection - secondary injection and multi statement injection
What changes will PMP certification bring?
随机推荐
Complete code of C language neural network and its meaning
《二》标签
If you‘re running pod install manually, make sure flutter pub get is executed first.
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
第一篇论文的写作流程
ThinkPHP关联预载入with
人体传感器好不好用?怎么用?Aqara绿米、小米之间到底买哪个
Using thread class and runnable interface to realize the difference between multithreading
The founder has a debt of 1billion. Let's start the class. Is it about to "end the class"?
一个酷酷的“幽灵”控制台工具
2039: [Bluebridge cup 2022 preliminaries] Li Bai's enhanced version (dynamic planning)
ServiceMesh主要解决的三大痛点
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
Leetcode(417)——太平洋大西洋水流问题
DFS, BFS and traversal search of Graphs
拿到PMP认证带来什么改变?
LabVIEW在打开一个新的引用,提示内存已满
Weebly移动端网站编辑器 手机浏览新时代
痛心啊 收到教训了
基于Bevy游戏引擎和FPGA的双人游戏