当前位置:网站首页>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 
边栏推荐
- The most complete learning rate adjustment strategy in history LR_ scheduler
- np.random.shuffle与np.swapaxis或transpose一起时要慎用
- Salesforce 容器化 ISV 场景下的软件供应链安全落地实践
- How to design API interface and realize unified format return?
- [Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
- 【问道】编译原理
- When knative meets webassembly
- Dbsync adds support for mongodb and ES
- LabVIEW在打开一个新的引用,提示内存已满
- NiO related knowledge points (I)
猜你喜欢

《二》标签
![[Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails](/img/e0/04f06d464e77012fbfc919e07cbb66.png)
[Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails

10 distributed databases that take you to the galaxy

Is PMP really useful?

If you‘re running pod install manually, make sure flutter pub get is executed first.

Window scheduled tasks

AttributeError: module ‘torch._ C‘ has no attribute ‘_ cuda_ setDevice‘

How to design API interface and realize unified format return?
[email protected] Mapping relatio"/>Why JSON is used for calls between interfaces, how fastjson is assigned, fastjson 1.2 [email protected] Mapping relatio

CentOS 7.9安装Oracle 21c历险记
随机推荐
pytest测试框架——数据驱动
JS 的 try catch finally 中 return 的执行顺序
人体传感器好不好用?怎么用?Aqara绿米、小米之间到底买哪个
与利润无关的背包问题(深度优先搜索)
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
U++ 元数据说明符 学习笔记
Leetcode minimum difference in student scores
高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍
LinkedBlockingQueue源码分析-初始化
Development thoughts of adding new requirements in secondary development
Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
Batch normalization (Standardization) processing
U++ 游戏类 学习笔记
U++ metadata specifier learning notes
磁盘监控相关命令
全链路压测:影子库与影子表之争
If you‘re running pod install manually, make sure flutter pub get is executed first.
Servicemesh mainly solves three pain points
Linkedblockingqueue source code analysis - initialization
The execution order of return in JS' try catch finally