Opened 16 years ago

Last modified 13 years ago

#7121 closed

queryset-rf does not always honor cache — at Initial Version

Reported by: lars@… Owned by: nobody
Component: Uncategorized Version: dev
Severity: Keywords: qsrf-cleanup queryset-rf, cache
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Playing around in the shell and watching postgresql.log I found out the following:

Method a)

list = Article.objects.filter(idgt=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(idgt=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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top