I want to get the first 500 results from a large database that match the given filter query.
I am currently using the following (terribly inefficient) method.
results = Entries.objects.filter(text__icontains="somequery")[0:500]
But I think this query loads the entire database into memory and then truncates the results. It is terribly slow.
Is there a more elegant way to do this? Thanks!
infiniteloop
source share