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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -