On Sat, Sep 19, 2020 at 6:14 PM misraX x <fordax05@gmail.com> wrote:
I believe you are searching for queryset and SQL limits, if so take a look at--On Fri, Sep 18, 2020 at 7:00 PM אורי <uri@speedy.net> wrote:Hi,I have a code with a query:qs = User.objects.active(
gender__in=user.speedy_match_profile.gender_to_match,
diet__in=user.speedy_match_profile.diet_to_match,
smoking_status__in=user.speedy_match_profile.smoking_status_to_match,
relationship_status__in=user.speedy_match_profile.relationship_status_to_match,
speedy_match_site_profile__gender_to_match__contains=[user.gender],
speedy_match_site_profile__diet_to_match__contains=[user.diet],
speedy_match_site_profile__smoking_status_to_match__contains=[user.smoking_status],
speedy_match_site_profile__relationship_status_to_match__contains=[user.relationship_status],
date_of_birth__range=age_ranges,
speedy_match_site_profile__min_age_to_match__lte=user.get_age(),
speedy_match_site_profile__max_age_to_match__gte=user.get_age(),
speedy_match_site_profile__height__range=(self.model.settings.MIN_HEIGHT_TO_MATCH, self.model.settings.MAX_HEIGHT_TO_MATCH),
speedy_match_site_profile__not_allowed_to_use_speedy_match=False,
speedy_match_site_profile__active_languages__contains=[language_code],
).exclude(
pk__in=[user.pk] + blocked_users_ids + blocking_users_ids,
).prefetch_related(
"likes_to_user",
"friends",
).order_by('-speedy_match_site_profile__last_visit')
user_list = qs[:2400]
matches_list = []
for other_user in user_list:... # The rest of my code.I'm using prefetch_related and I also limit the query to the first 2,400 users. So if, for example, there are 24,000 users in the original query - will the
prefetch_related function be executed for all of them, or only the first 2,400? I think it should be 2,400 but I can't find it documented. Do you know where is the documentation for this?Thanks,Uri.אורי
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABD5YeGjP%2BwDN6AWAz-3L2f4fUvjoh7k8hxTr3jTy1bcZtyWOA%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMiFc-8fGeUZr8ZjQEg3gEykbto5htTSraMcbD_JYkDu%3DhX57g%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABD5YeEBzW%2Bf-is%2ByAAHdnujkpr3spWKAk6rGUy6rZrqRNK6JQ%40mail.gmail.com.
No comments:
Post a Comment