When I used my first ORM, I wondered “why didn’t they include a random() method?” It seemed like such an easy thing to add. While there are many reasons you may want to pull a record out of your database at random, you shouldn’t be using SQL’s RANDOM() function unless you’ll only be randomizing a limited number of records. In this post, we’ll examine how such a simple-looking SQL operator can cause a lot of performance pain, and a few different techniques we can use to fix it.
As you might know, I run CodeTriage, the best way to get started helping open source, and I’ve written about improving the database performance on that site:
No comments:
Post a Comment