performance - Selecting a random row in Django, quickly -


i have view returns data associated randomly-chosen row 1 of models. i'm aware of order_by('?') , performance problems, , want avoid using order_by('?') in view.

because data in model changes (if @ all), i'm considering approach of caching entire model in memory between requests. know how many records i'm dealing with, , i'm comfortable taking memory hit. if model change somehow, regenerate cache @ moment.

is strategy reasonable? if so, how implement it? if not, how can select random row model changes if @ all?

if know ids of object, , range can randomize on ids, , query database


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -