当前位置:网站首页>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 
边栏推荐
- Pointer and array are input in function to realize reverse order output
- Appium practice | make the test faster, more stable and more reliable (I): slice test
- Using thread class and runnable interface to realize the difference between multithreading
- 最长回文子串(动态规划)
- Is PMP really useful?
- U++4 interface learning notes
- Sublime tips
- np.random.shuffle与np.swapaxis或transpose一起时要慎用
- Markdown editor
- 动态生成表格
猜你喜欢

Batch normalization (Standardization) processing

CentOS 7.9安装Oracle 21c历险记

装饰器基础学习02

Understand common network i/o models

Pointer and array are input in function to realize reverse order output

pytest测试框架——数据驱动

torch optimizer小解析

记录一次压测经验总结

最长回文子串(动态规划)

Ansible报错:“msg“: “Invalid/incorrect password: Permission denied, please try again.“
随机推荐
Mysql database (basic)
STM32F103 realize IAP online upgrade application
2.证券投资基金的概述
U++4 interface learning notes
sublime使用技巧
Auto.js 获取手机所有app名字
Test interview | how much can you answer the real test interview question of an Internet company?
If you‘re running pod install manually, make sure flutter pub get is executed first.
DFS, BFS and traversal search of Graphs
Full link voltage test: the dispute between shadow database and shadow table
记录一次压测经验总结
No experts! Growth secrets for junior and intermediate programmers and "quasi programmers" who are still practicing in Universities
Error: No named parameter with the name ‘foregroundColor‘
局部变量的数组初始化问题
U++ metadata specifier learning notes
2. Overview of securities investment funds
最长回文子串(动态规划)
SQL injection HTTP header injection
Stm32f103ze+sht30 detection of ambient temperature and humidity (IIC simulation sequence)
Timer create timer