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
Post a Comment