That's... difficult, if you mean "by votes placed in the last month or three months". There's 10,000 poems, and it's a slow operation to actually calculate a poem's average; at least in "internet time". At least, I don't know of a better way than what I'm doing, and that takes about (runs "explain analyze") 7.5 seconds to get the "current average" of every poem. What I do to get around that is keep the running tally on the poem itself and update that when either the poem is edited or someone votes on it.
SELECT id, voteaverage(id) FROM poemranker_poems: 7483.31 msec
SELECT id, avg FROM poemranker_poems: 190.28 msec
|