Opened 2 months ago

Closed 5 weeks 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: master
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 Changed 2 months ago by Simon Charette

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?

comment:2 in reply to:  1 Changed 2 months ago by Raphaël Hertzog

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 Changed 2 months ago by Tim Graham

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

comment:4 Changed 2 months ago by Herbert Fortes

Cc: Herbert Fortes added

comment:5 Changed 2 months ago by oliver

Owner: changed from nobody to oliver
Status: newassigned

comment:6 Changed 2 months ago by oliver

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

comment:8 Changed 8 weeks ago by Tim Graham

Has patch: set
Patch needs improvement: set

comment:9 Changed 5 weeks ago by Tim Graham

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 Changed 5 weeks ago by Tim Graham <timograham@…>

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