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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -