<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Random on ads' corner</title><link>https://andreas.scherbaum.la/tags/random/</link><description>Recent content in Random on ads' corner</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 04 Feb 2007 21:50:30 +0100</lastBuildDate><atom:link href="https://andreas.scherbaum.la/tags/random/index.xml" rel="self" type="application/rss+xml"/><item><title>Ringbuffer in SQL</title><link>https://andreas.scherbaum.la/post/2007-02-04_ringbuffer-in-sql/</link><pubDate>Sun, 04 Feb 2007 21:50:30 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2007-02-04_ringbuffer-in-sql/</guid><description>&lt;p&gt;On a student platform we show, on every page, a random user in the upper right corner. Because we have over 11.000 users, the database has to select all matching users and sort them by &lt;code&gt;random()&lt;/code&gt;. Thats very expensive and one of the longest running queries in the current version. And because we are currently redeveloping the whole platform, I decided to try something different for the random user. The user must not be really random, it should be enough to just display a different user every time the page is displayed. My idea was to implement a ringbuffer in SQL and forward the pointer to the next user in the buffer if we need to search the next random user.&lt;/p&gt;</description></item></channel></rss>