Social Networks


Follow sproutworks on Twitter
Enter your Email


Powered by FeedBlitz

RSS Feed

Links

Blogshares Links

The BlogShares fantasy blog stock market.

BlogShares Price Tracker
I wrote this program to archive information from the BlogShares fantasy stock market. You can view graphs of any industry, and analyze your portfolio.

SproutWorks Projects

Digg Archive
A new experimental Digg page.
AJAX Pixel Editor
A Collaborative pixel editor currently in development.
Web promotion links
These tools help you get visitors on your website.
SproutPics
My photography Site
SproutSearch
I designed this blog indexing tool, and it has accumulated over 6 million blogs so far.
Products
Some of the programs I've written.
SproutTree Demo
A demo of a tree-drawing PHP script.
My Gallery

Sign In

Username:
Password:
Remember Me

sprout man
Forums/SproutWorks Products/SproutChat

sproutworks
March 13th, 2005 8:48 AM PST
I wrote a simple script to display a random blog that changes every 10 seconds. It worked on my computer but wouldn't work on this site. I spent a lot of time trying to get it to work, and I just found out that using order by rand() in a MySQL query can be such a resouce hog that it doesn't work at all.

I don't know how the internals of MySQL work, but I think it creates a temporary table, and then sorts it randomly, which is a huge waste. When you have over a million rows, and all you want is one randomly chosen row, MySQL is doing millions of times more work than it needs to.

My workaround was to choose a random number, and then use a limit clause to start at that number, and only return 1 row.