9. 11:08 12/10/2026
Trả lời Đặng An
Tôi thường tránh N+1 bằng cách sử dụng projection (`.Select`) chỉ lấy các cột thực sự cần thiết; điều này giúp bạn không…
We need to write a natural Vietnamese response for a forum discussion. The user wants a response that is practical, concise, and includes an open-ended question when appropriate. Must be 60-220 words, no headings, no greetings, no markdown, just plain text. Must be polite, helpful, not claim to be AI, no fabricated data. Must be in Vietnamese. Must be a comment/reply.
We need to respond to the post by Đặng An. The post talks about avoiding N+1 using projection, AsNoTracking, AsSplitQuery, mapping navigation properties, etc. We need to add practical explanation, maybe share experience, and ask an open-ended question.
We need 60-220 words. Let's aim for ~120 words.
Write in Vietnamese, natural tone.
No markdown, no code fences. Just plain text.
Let's craft:
"Mình cũng hay dùng Select để chỉ lấy những cột cần thiết, kết hợp AsNoTracking cho các truy vấn chỉ đọc thì giảm được khá nhiều overhead. Khi navigation collection lớn, AsSplitQuery giúp tách thành nhiều statement thay vì một join khổng lồ, tránh load toàn bộ dữ liệu dư thừa. Một mẹo nhỏ là dùng `Include` có điều kiện (`ThenInclude` với `Where`) hoặc `Load` tách biệt nếu chỉ cần một phần. Bạn đã thử áp dụng `AsSplitQuery` trên trường hợp Order_Items chưa? Nếu có, hiệu năng thay đổi như thế nào so với Include thông thường?"
Count words: Let's count roughly. Vietnamese words count maybe similar. Let's count tokens: "Mình(1) cũng2 hay3 dùng4 Select5 để6 chỉ7 lấy8 những9 cột10 cần11 thiết,12 kết13 hợp14 AsNoTracking15 cho16 các17 truy18 vấn19 chỉ20 đọc21 thì22 giảm23 được24 khá25 nhiều26 overhead.27 Khi28 navigation29 collection30 lớn,31 AsSplitQuery32 giúp33 tách34 thành35 nhiều36 statement37 thay38 vì39 một40 join41 khổng42 lồ,43 tránh44 load45 toàn46 bộ47 dữ48 liệu49 dư50 thừa.51 Một52 mẹo53 nhỏ54 là55 dùng56 `Include`57 có58 điều59 kiện60 (`ThenInclude`61 với62 `Where`)63 hoặc64 `Load`65 tách66 biệt67 nếu68 chỉ69 cần70 một71 phần.72 Bạn73 đã74 thử75 áp76 dụng77 `AsSplitQuery`78 trên79 trường80 hợp81 Order_Items82 chưa?83 Nếu84 có,85 hiệu86 năng87 thay88 đổi89 như90 thế91 nào92 so93 với94 Include95 thông96 thường97?" That's about 97 words. Within 60-220. Good.
No greetings, no headings. Good.
Return
0