Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should speed-up case-insensitive queries at least on postgreSQL. Some benchnmarking: - with cache * cold cache ``` >>> import timeit >>> timeit.timeit("User.objects.get_anonymous_user()", number=100, setup="from inyoka.portal.user import User; from django.conf import settings") 1.2246114060000082 ``` * warm cache (mind the additional 0) ``` >>> import timeit >>> timeit.timeit("User.objects.get_anonymous_user()", number=1000, setup="from inyoka.portal.user import User; from django.conf import settings") 0.29570037799999227 ``` - without index (before applying the migration of this commit) ``` >>> import timeit >>> timeit.timeit("User.objects.get(username__iexact=settings.ANONYMOUS_USER_NAME)", number=1000, setup="from inyoka.portal.user import User; from django.conf import settings") 51.55617682000002 ``` - with index ``` >>> import timeit >>> timeit.timeit("User.objects.get(username__iexact=settings.ANONYMOUS_USER_NAME)", number=1000, setup="from inyoka.portal.user import User; from django.conf import settings") 0.9243776870002876 ``` This can be also seen in the EXPLAIN (mind the filter instead of get, otherwise an explain is not possible) ``` >>> print(User.objects.filter(username__iexact=settings.ANONYMOUS_USER_NAME).explain(verbose=True)) Bitmap Heap Scan on public.portal_user (cost=18.18..2544.97 rows=743 width=447) Output: id, password, last_login, is_superuser, username, email, status, date_joined, banned_until, avatar, jabber, signature, location, gpgkey, website, launchpad, settings, forum_read_status, member_title, icon Recheck Cond: (upper((portal_user.username)::text) = 'ANONYMOUS'::text) -> Bitmap Index Scan on upper_username_idx (cost=0.00..17.99 rows=743 width=0) Index Cond: (upper((portal_user.username)::text) = 'ANONYMOUS'::text) ```
- Loading branch information