On 11 Nov 2016, at 8:26am, Cecil Westerhof <[email protected]> wrote:
> I want to select several quotes, with the following constraints: > - As long there are quotes that are not selected, no record that was > already selected should be selected. > - How longer ago a record was selected, the bigger the chance should > be that it is selected. > > What would the best way to do this? Get rid of the first requirement by choosing an appropriate 'startup' last-seen-timestamp for existing quotes. Then you don't have to include the logic for selecting by it in your software. Logically speaking this should be a very early date. Perhaps 10 years before the day the quote was added. That would simulate the quote not having been seen for 10 years. As for selecting a quote, why not just select the quote with the earliest last-seen-timestamp ? It can be done in one SELECT operation which uses an index, so it'll happen almost instantly. CREATE INDEX q_ls ON quotes (lastSeen); SELECT id,quoteText FROM quotes ORDER BY lastSeen LIMIT 1; UPDATE quotes SET lastSeen=<now> WHERE id=<id from the previous command>; Simon. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

