Friday, December 01, 2017

Say No to Randos in Your Database

DZone Database Zone
Say No to Randos in Your Database
Say No to Randos in Your Database

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:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...