I need to retrieve 5 objects that match a certain complex criteria, and I can't/don't want to pass that criteria to the WHERE clause(filter in django), so I need to iterate over the results, testing each record for the criteria until I get my 5 objects, after that I want to throw the query set away and never see it again.
In most cases, the records I need will be at the beginning of the query set, in the worst case, it will be at its end. The table is huge and I only need 5 records. So my question is: How do I iterate over a query set without having django to cache the results? This must be done in a way that neither the sql engine/django storing/caching the results anywhere.