GeeWee / django-auto-prefetching

Automatic prefetching for Django
MIT License
231 stars 18 forks source link

How to use your package? #2

Closed dfrankow closed 5 years ago

dfrankow commented 5 years ago

I am having performance issues with drf. I feel like your library might help, but I can't figure out how to use it, or if it pertains. All the things I try result in no impact. Please see the stackoverflow question.

I'd appreciate any thoughts.

GeeWee commented 5 years ago

Yeah the documentations been in a bit of a sorry state, I've updated it to make it more clear. Unfortunately I don't think it's going to help much with inserts, but feel free to give it a shot and let me know if it helps you!

dfrankow commented 5 years ago

Gotcha.

The stackoverflow question mentions four queries. The last one (4) is an insert. The third one I was able to turn off. But numbers 1 and 2 are foreign-key queries, one of which is the same query repeated over and over because fk1 doesn't change. This feels like it would be helped by a pre-fetch. But, again, I can't get it to work.

GeeWee commented 5 years ago

Unfortunately Django checks foreign keys on insert, even though things are prefetched. I think you might be able to get around it by using bulk_insert, but unsure.