id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 7121 Slicing on QuerySet bypasses result_cache lars@… nobody "Playing around in the shell and watching postgresql.log I found out the following: Method a) {{{ list = Article.objects.filter(id__gt=130).order_by('-id')[0:2] list[0] # Performs SQL query with LIMIT 1 list[1] # Performs another SQL query with LIMIT 1 OFFSET 2 }}} Method b) {{{ list = Article.objects.filter(id__gt=130).order_by('-id')[0:2] list # Performs an SQL query with LIMIT 2 list[0] # Hits the cache list[1] # Hits the cache }}} Calling {{{list[0]}}} afterwards will invoke the SQL query with LIMIT 1 Calling {{{list[1]}}} after this will invoke another query with LIMT 1 OFFSET 1 b) Calling just ""list"" afterwards first and then calling {{{list[0]}}} and {{{list[1]}}} will honor the cache and therefore only one SQL query gets fired. " closed Uncategorized dev wontfix qsrf-cleanup queryset-rf, cache Design decision needed 0 0 0 0 0 0