Install any skill in seconds. Free to start, no credit card required.
Get Started Free →doccker/query-performance-safety
当代码涉及循环内查询、批量 ID 查询、IN 子句、BFS/递归遍历、嵌套 service 调用时触发。防止 N+1 查询、IN 子句过长、递归内存炸裂等性能陷阱。
Passed 19 of 22 test cases with the skill, and 16 of 22 without it.
and 4 more in the full report
5 fixed14 passed either way1 still failing2 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 5 test cases the skill fixed. Same model, same prompt, with and without the skill.
In a multi-tenant Spring Data JPA application, what standard method naming pattern should be used for a repository method that fetches a batch of entities by IDs with tenant isolation?
| Checked | Without skill | With skill |
|---|---|---|
| Names the repository method `findByTenantIdAndIdIn(Long tenantId, Collection<Long> ids)`. | Missed | Passed |
The instructions your model reads when the skill loads.
当代码涉及数据库或远程服务的批量查询时,防止 N+1、IN 子句过长、递归无界等高频性能陷阱。
与
multi-tenant-safety配合:本 skill 关注「查询效率」,租户隔离遵循后者。
场景: for / stream / forEach 内部直接调用 repo.findById(...) 或同等单条远程调用
每次循环触发一次 SQL/HTTP,N 个元素就是 N 次往返。100 元素 = 100 次 SQL,1000 元素就是 1000 次。本地开发数据少看不出来,生产环境直接拖垮接口。
只要在 service / handler 方法里看到以下任一模式,立即怀疑 N+1:
// ❌ 模式 1:显式 for
for (Order o : orders) {
User u = userRepository.findById(o.getUserId()).orElse(null);
}
// ❌ 模式 2:stream 链
orders.stream()
.map(o -> userRepository.findById(o.getUserId()))
.collect(...);
// ❌ 模式 3:辅助方法被循环调用
for (Item i : items) {
enrichItem(i); // 里面又 findById 一次
}
// ❌ 模式 4:嵌套调用
List<X> list = repoA.findByY(y);
test cases passed, vs 16 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.