๐Ÿ’ก ๐—ง๐—ถ๐—ฝ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐——๐—ฎ๐˜† โ€” ๐——๐—ท๐—ฎ๐—ป๐—ด๐—ผ ๐——๐—ถ๐—ฑ ๐˜†๐—ผ๐˜‚ ๐—ธ๐—ป๐—ผ๐˜„? Using "only()" and "defer()" ...๐Ÿ’ก ๐—ง๐—ถ๐—ฝ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐——๐—ฎ๐˜† โ€” ๐——๐—ท๐—ฎ๐—ป๐—ด๐—ผ ๐——๐—ถ๐—ฑ ๐˜†๐—ผ๐˜‚ ๐—ธ๐—ป๐—ผ๐˜„? Using "only()" and "defer()" ...
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Tonye's avatar
pro
โ€ข Apr 4
๐Ÿ’ก ๐—ง๐—ถ๐—ฝ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐——๐—ฎ๐˜† โ€” ๐——๐—ท๐—ฎ๐—ป๐—ด๐—ผ
๐——๐—ถ๐—ฑ ๐˜†๐—ผ๐˜‚ ๐—ธ๐—ป๐—ผ๐˜„? Using "only()" and "defer()" in Django can significantly reduce query payload when you donโ€™t need every model field.
๐Ÿ”ง "only()" โ†’ Load ๐˜ฐ๐˜ฏ๐˜ญ๐˜บ ๐˜ด๐˜ฑ๐˜ฆ๐˜ค๐˜ช๐˜ง๐˜ช๐˜ค ๐˜ง๐˜ช๐˜ฆ๐˜ญ๐˜ฅ๐˜ด ๐Ÿ”ง "defer()" โ†’ Load ๐˜ฆ๐˜ท๐˜ฆ๐˜ณ๐˜บ๐˜ต๐˜ฉ๐˜ช๐˜ฏ๐˜จ ๐˜ฆ๐˜น๐˜ค๐˜ฆ๐˜ฑ๐˜ต ๐˜ด๐˜ฑ๐˜ฆ๐˜ค๐˜ช๐˜ง๐˜ช๐˜ฆ๐˜ฅ ๐˜ง๐˜ช๐˜ฆ๐˜ญ๐˜ฅ๐˜ด
Why it matters:
- Less data transferred from DB
- Lower memory usage
- Faster responses for large models
Smart field selection = better performance.
#Python #BackendDevelopment #WebDevelopment #PerformanceOptimization
Post image
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started