Opened 6 years ago

Closed 6 years ago

#29584 closed Cleanup/optimization (fixed)

Implement an optimized version of get_many() for the db cache backend

Reported by: Raphaël Hertzog Owned by: oliver
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: Herbert Fortes Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation of get_many in django.core.cache.backends.base.BaseCache implies that the implementation of the method for a database backend can be much faster:

        Fetch a bunch of keys from the cache. For certain backends (memcached,
        pgsql) this can be *much* faster when fetching multiple values.

However when I look into django.core.cache.backends.db I don't see any get_many implementation meaning that retrieving 1000 entries from the cache will do 1000 queries instead of just one. This is really sad and makes this backend a no-go for any heavy usage of the cache.

Change History (10)

comment:1 by Simon Charette, 6 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted
Version: 1.11master

It should be straightforward to implement and test using assertNumQueries.

Are you interested in working on a patch?

in reply to:  1 comment:2 by Raphaël Hertzog, 6 years ago

Replying to Simon Charette:

Are you interested in working on a patch?

It's not among my priorities, sorry. But once there's a fix, I hope it will be backported to 1.11.

comment:3 by Tim Graham, 6 years ago

This doesn't qualify for a backport based on our supported versions policy.

comment:4 by Herbert Fortes, 6 years ago

Cc: Herbert Fortes added

comment:5 by oliver, 6 years ago

Owner: changed from nobody to oliver
Status: newassigned

comment:6 by oliver, 6 years ago

Can I claim this ticket? I'm interested in this

comment:8 by Tim Graham, 6 years ago

Has patch: set
Patch needs improvement: set

comment:9 by Tim Graham, 6 years ago

Patch needs improvement: unset
Summary: cache.backends.db does not implement get_manyImplement an optimized version of get_many() for the db cache backend
Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In abd0ad76:

Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend.

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