Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefetch related #181

Open
robslotboom opened this issue Oct 15, 2016 · 8 comments
Open

prefetch related #181

robslotboom opened this issue Oct 15, 2016 · 8 comments

Comments

@robslotboom
Copy link

Maybe interesting.

To limit the amount of queries you can do the following in the search view:

self.object_list = self.get_queryset().prefetch_related('object')

Cheers,

Robert

@robslotboom
Copy link
Author

Unfortunately this is only supported if the query is restricted to one ContentType...

@etianen
Copy link
Owner

etianen commented Oct 17, 2016

Unfortunately, this caused major bugs with Django, and so had to be taken out.

I'll leave open for now, however, as it should go back into once Django has released a few more versions and I can drop support for the broken ones.

@etianen etianen closed this as completed Sep 22, 2017
@etianen etianen reopened this Sep 22, 2017
@valentijnscholten
Copy link

I'm using prefetch with watson search and so far it works fine.

products = watson.search(clean_query, models=(Product,)).prefetch_related('object', 'object__engagement_set')

@etianen
Copy link
Owner

etianen commented Mar 23, 2020

Excellent. I'd take a MR that puts this feature back in.

@robslotboom
Copy link
Author

2016...

@etianen
Copy link
Owner

etianen commented Mar 23, 2020

Pardon?

@robslotboom
Copy link
Author

That’s 4 years back :-D

@valentijnscholten
Copy link

valentijnscholten commented Sep 9, 2020

Still I think it only works if you have only 1 model / content_type in the results and you have to know which one up front.
Unless you only want to prefetch object, which is in itself already a performance improvement if you access it in your search results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants