No video

Django Query Optimization / select_related & prefetch_related / django-debug-toolbar / N+1 Problem

  Рет қаралды 11,792

BugBytes

BugBytes

Күн бұрын

Пікірлер: 80
@bugbytes3923
@bugbytes3923 4 ай бұрын
Playlist link: kzfaq.info/get/bejne/e9lypKyL0riWhZc.html
@anthonymwangi6889
@anthonymwangi6889 7 ай бұрын
You are the best thing that has ever happened to Django. Thank you. The best thing we can do, is buy you coffee. You deserve it.
@bugbytes3923
@bugbytes3923 7 ай бұрын
Haha bold claim 😃 But thank you, that's amazing to hear!
@Peterstavrou
@Peterstavrou Жыл бұрын
I've watched so many Django videos and you're the first person I've come across that talks about this. Great work once again!
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot Peter!
@alexdin1565
@alexdin1565 Жыл бұрын
Thanks, You have taken Django to another level❤
@streamocu2929
@streamocu2929 Жыл бұрын
love your cool advanced content... you are my django master. thank you for sharing ❤
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot, really appreciate that!
@ali-cu1ne
@ali-cu1ne 5 ай бұрын
Thanks, You have taken me to another level in django
@bugbytes3923
@bugbytes3923 5 ай бұрын
Thanks a lot, glad to hear that!
@devlin1234
@devlin1234 Ай бұрын
excellent, thanks again! been watching your videos for a while now.. very well explained!
@bugbytes3923
@bugbytes3923 Ай бұрын
Thanks a lot - great to hear that! Thank you for watching
@adhd_arti
@adhd_arti Жыл бұрын
Your channel is peace of gold on youtube. Exact hit that I'd been searching for
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks so much for that comment, really appreciate it!
@guledomer
@guledomer Жыл бұрын
Great content, easy concise and well paced. You are a real masterclass educator.
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot, really appreciate that comment ! Glad you liked the video.
@georgewestbrook4512
@georgewestbrook4512 4 ай бұрын
Thanks alot, was wondering why my application was so slow and this completely fixed it. Love this channel!
@bugbytes3923
@bugbytes3923 4 ай бұрын
Glad to hear it! Thanks a lot!
@open-source243
@open-source243 3 ай бұрын
Thank you so much for this great channel 🥰🥰
@lfc5times130
@lfc5times130 9 ай бұрын
I have used prefetch and select related blindly in real time project (Not knowing in-depth) and query time was reduced. But this explanation is too good and I got to know the real use. Thank you so much man.
@bugbytes3923
@bugbytes3923 9 ай бұрын
Thanks a lot! Really glad to hear it was helpful!
@satishshah3861
@satishshah3861 5 ай бұрын
You are true genius❤
@bugbytes3923
@bugbytes3923 5 ай бұрын
Thanks a lot!
@saulo2264
@saulo2264 Ай бұрын
Nice video! Very helpful.
@bugbytes3923
@bugbytes3923 Ай бұрын
Thank you!
@wanderingtravellerAB99
@wanderingtravellerAB99 9 ай бұрын
Dude i love ur stuff. For me the special highlight tho is every time you say boolean I hear boullion
@bugbytes3923
@bugbytes3923 9 ай бұрын
Haha thanks, some words do come across strangely in a Scottish accent! Thanks for watching!
@ewartmouton
@ewartmouton 2 ай бұрын
Thanks
@bugbytes3923
@bugbytes3923 2 ай бұрын
Thanks so much for this, much appreciated!
@rangabharath4253
@rangabharath4253 Жыл бұрын
Awesome as always 🥳🎉
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot 🙏
@codethinkersacademy2794
@codethinkersacademy2794 23 күн бұрын
awesome
@bugbytes3923
@bugbytes3923 21 күн бұрын
Thanks a lot!
@onnot701
@onnot701 Жыл бұрын
thanks
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks for watching!
@repotranstech9614
@repotranstech9614 Жыл бұрын
Very important video.
@bugbytes3923
@bugbytes3923 Жыл бұрын
Cheers!
@aashayamballi
@aashayamballi Жыл бұрын
Thank you
@bugbytes3923
@bugbytes3923 Жыл бұрын
You're welcome, thanks for watching!
@rprana12777
@rprana12777 10 ай бұрын
Love the content
@bugbytes3923
@bugbytes3923 10 ай бұрын
Thanks a lot!
@buxx5334
@buxx5334 Жыл бұрын
I hope your channel be 1m subs ❤
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot!!
@Dorso2009
@Dorso2009 11 ай бұрын
Excellent video!! Thank you!
@bugbytes3923
@bugbytes3923 11 ай бұрын
Thanks a lot!
@TomislavMiletic
@TomislavMiletic Жыл бұрын
Thank you!
@bugbytes3923
@bugbytes3923 Жыл бұрын
You're welcome, thanks for watching Tomislav!
@wiki-infodevelopment3369
@wiki-infodevelopment3369 Жыл бұрын
Sure it is very good
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks!
@Coden69
@Coden69 Жыл бұрын
Amazing
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thank you!
@HalloWorld123
@HalloWorld123 6 ай бұрын
Thank you, sir
@the-antroy
@the-antroy Жыл бұрын
Nice, Thanks!
@bugbytes3923
@bugbytes3923 Жыл бұрын
You’re welcome and thanks for watching!
Жыл бұрын
Great!
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks a lot!
@dodokwak
@dodokwak Жыл бұрын
Awesome!
@frameff9073
@frameff9073 Жыл бұрын
thank
@bugbytes3923
@bugbytes3923 Жыл бұрын
Thanks!
@shivar8023
@shivar8023 8 ай бұрын
awesome video❤... could you also post a video on caching in django
@bugbytes3923
@bugbytes3923 8 ай бұрын
Thanks - yes I’ll be doing some Caching + Redis stuff soon!
@seeker511
@seeker511 7 ай бұрын
Great tutorial! but can you let me know, why we are configuring django to server static files explicitly, when its already being done by runserver implicitly?
@IMTyranus
@IMTyranus 6 ай бұрын
Instead of using the 'ratings' related_name and then filtering the queryset, could you have created another Prefetch object for that like you did with monthly sales and call it five_star_ratings or something?
@mohamedazizchibani6004
@mohamedazizchibani6004 9 ай бұрын
nice video ! Do you have any suggestions for debugging the queries with django rest framework ?
@joshajiniran
@joshajiniran Жыл бұрын
Is debugtoolbar still usable for rest APIs?
@user-et7hv3oc8h
@user-et7hv3oc8h 3 ай бұрын
Is it mandatory for me to work on templates for each endpoints if i wish to use the django debug toolbar?
@sibik5695
@sibik5695 11 ай бұрын
I have updated date of sale of a restaurant to two months before. But still I'm getting the sale object
@TheApgreyd
@TheApgreyd Жыл бұрын
What about ur Django-leaflet series?
@bugbytes3923
@bugbytes3923 Жыл бұрын
I’ll hopefully create some more soon!
@Peterstavrou
@Peterstavrou Жыл бұрын
Is the management/command pretty much the same as the scripts in the extensions just best practice to put code to import data as a command rather than a script? Also, I think there may be an error with the Prefetch() code because if I change "month_ago" to "two_days_ago": two_days_ago = timezone.now() - timezone.timedelta(days=2) and print: Sale.objects.filter(datetime__gte=two_days_ago) I get a queryset with 2 objects but when I print the below I get a queryset of 6 Restaurant.objects.prefetch_related('ratings', two_days_ago).filter(ratings__rating=5) and when I print the totals it's exactly the same as when we get all of the Sales rather than the Sales for a specific date. It's a list with 4 results. Hope this makes sense and not an issue of how I coded along.
@bugbytes3923
@bugbytes3923 Жыл бұрын
Hey Peter - are you building a Prefetch() object in this query? It looks like you're passing in a datetime object - "two_days_ago" - to the "prefetch_related" query above?
@user-zv7gf9zv2j
@user-zv7gf9zv2j Ай бұрын
same problem get , whenever i put , filter(ratings__rating=5, sales__date_time__range=[month_ago_30, timezone.now()- timezone.timedelta(days=3)]) then its work
@bengabp
@bengabp 17 күн бұрын
what if im using django rest framework and im working on api ?
@bugbytes3923
@bugbytes3923 17 күн бұрын
@@bengabp on your api you’ll usually be fetching data from the database, so all the same concepts will apply
@bengabp
@bengabp 17 күн бұрын
@@bugbytes3923 yeah but where does the sidebar show ? my api doesnt have html page, or do i have to add atleast a form or html page ?, i use postman to test my api
@Septumsempra8818
@Septumsempra8818 Жыл бұрын
N+1 has been kicking my @ss
@bugbytes3923
@bugbytes3923 Жыл бұрын
Hope this can help 😁
@Septumsempra8818
@Septumsempra8818 Жыл бұрын
​@bugbytes3923 honestly it's made things kinda worse. It's sped up my landing page etc, but it's forcing me to redesign my models and come to terms with how little I understand databases.
@Ahmed-gz7zq
@Ahmed-gz7zq 9 ай бұрын
hello sir, thanks for the explanation, i just wanted to know when will the select_related not working, I'm using a different ways to implement it here: ` loans = self.lending_loans.select_related('lender').filter(lender_loan_status__in=[Loan.STATUS.funded, Loan.STATUS.completed]) ` Where lending_loans is the related name of the the FK inside the loan model.
@jonathanbriones3235
@jonathanbriones3235 2 ай бұрын
Great video! restaurants = Restaurant.objects.prefetch_related('rating_set', monthly_sales).filter(rating__rating=5) restaurants.annotate(total=Sum('sale__income')) I'm cross referencing the values printed out on the terminal vs the dB Browser table. The Sum value doubles up for Restaurant rows when the query set returns the same restaurant name twice (i.e. Bombay Bustle has 2-off 5-star entries, and it's sales are summed x2 - instead of the x1 which is expected). I tried troubleshooting with ChatGPT using the distinct() function on the filtered query set. It worked on the query set, but did not translate with the annotate function. Just wondering if anyone else encountered the same anomaly?
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 19 МЛН
The Joker saves Harley Quinn from drowning!#joker  #shorts
00:34
Untitled Joker
Рет қаралды 61 МЛН
Дай лучше сестре 🤗 #aminkavitaminka #aminokka #сестра
00:15
Аминка Витаминка
Рет қаралды 663 М.
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 24 М.
How to Use Select Related and Prefetch Related in Django
9:34
Pretty Printed
Рет қаралды 27 М.
DJANGO ORM QUERY OPTIMIZATION | Python
23:35
Andrey Ivanov | Python
Рет қаралды 4,4 М.
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 19 МЛН