I’ve just returned from Las Vegas, NV where Sin City Ruby 2024 was held at the Tropicana hotel.

This was a fun smaller gathering of Ruby programmers in the desert, put on by Jason Swett (Code with Jason) for the second time following the successful 2022 iteration.

While conferences include learning some new things, smaller ones like this are a great way to meet people one-on-one, creating new connections or strengthening old ones. The sunny 70s (F) Spring weather in Las Vegas helped too!

Presenting at Sin City Ruby 2024 Andrew Atkinson Presenting at Sin City Ruby 2024. Photo credit: Ernesto.

Presenting

This time around I was fortunate to present “Mastering Query Performance with PostgreSQL and Active Record,” which was a lot of fun. Since this wasn’t recorded, and since I’ll also be presenting at PgDay Chicago 2024 a month later, I decided to combine these talks but focus this one more on the Rails and Active Record side.

The presentation started from Active Record queries using the Rideshare app. The queries intend to efficiently find highly rated drivers to dispatch trip requests that Riders are placing in the app.

Although this is a fictional app, imagine that these queries are high criticality, running at high volume in a “dispatcher” type of loop as new trip requests arrive.

First we consolidated the queries into a single SQL query which I explained would be more efficient and possibly easier to optimize. From there I showed how I go about analyzing the tables, fields, and query conditions to design indexes. I iterated through around a half dozen indexes before landing on some good ones, verifying query plans using EXPLAIN (ANALYZE) from psql.

The main table had 50 million rows, and we observed a 99% query execution time from the cached (buffer cache) original execution time of 350ms with no indexes added.

I explained a “happy accident” while trying out a technique to pass in sorted data, resulted in a huge reduction in time as the plan changed to leverage PostgreSQL 16 “incremental sorting” capabilities.

We wrapped it up by converting the SQL CTE back into Active Record code, which gained CTE support in Rails 7.1.

Presenting at Sin City Ruby 2024 Andrew Atkinson Presenting at Sin City Ruby 2024. Photo credit: Ernesto.

Feedback

Before the presentation, when I said I was presenting on and consulting with PostgreSQL, someone (I missed their name) started to recommend “High Performance PostgreSQL for Rails” to me before I explained “that’s my book.” We had a nice little chuckle about that.

I got a lot of great feedback in person after the presentation. More on that later in this post. I also dropped in a quote from Cameron that was quite nice to receive.

I was absolutely floored you were able to get the performance of that query down to ~3ms, like… completely blown away. Amazing work. - Cameron

Thank you Cameron! Cameron and Dana and I were able to have lunch on the second day of the conference and we chatted about loads of things related to databases, SQL, indexes, and software teams.

Sin City Network and Podcasts

Attending this conference in 2022 turned out to be a great investment in building new connections for my career.

As I worked on my book over the last 2 years, and started to more heavily promote it last year on podcasts, I realized so many of my newer connections can be traced back to the 2022 conference.

Brittany Martin - The Ruby on Rails Podcast Episode

While Brittany is no longer a co-host of the podcast, she had an epic tenure serving as a co-host for years. I was really honored to be one of the last guests she had before signing off. Brittany and I met during a 5k fun run at the 2022 edition, which made it easier for me to reach out and pitch the podcast on an episode.

Jason Charnes - Remote Ruby Episode

Along with Andrew Mason and Chris Oliver, Jason Charnes and I have become friends over the last couple of years! All three of them have been supporters of my book, buying it and publicly praising it, and this has been super helpful and appreciated! I was honored to be on Remote Ruby a few months back, and the episode was a lot of fun.

Drew Bragg - Code and the Coding Coders Episode

I met Drew at the 2022 Sin City Ruby, and have been an admirer of his podcast format with three questions, and the depth of the conversations he and the guests get into. I really enjoyed our episode and Drew has been a big supporter of my book efforts as well, praising publicly and in-person at the conference. Thanks Drew!

Robby Russell - Maintainable Episode

Robby and I hadn’t met in person, but we did have the chance to meet a bit this time around. I’m a big fan of this podcast which focuses on the maintenance of software, and was honored to appear as a guest recently. We explored maintenance topics for a PostgreSQL database, and I really enjoyed discussing software maintenance as well. I wrote a blog post for the episode that went into greater detail.

Jason Swett - Multiple Episodes

Jason and I have met for a couple of episodes for Code With Jason, and I really appreciate the support and promotion that Jason has helped me with. One of those podcast episodes lead directly to a client consulting engagement, which was nice to see.

We even flipped the script, and I had the chance to interview Jason recently as we both were getting into consulting. You can find links to the Code With Jason episodes and more on my Speaking Opportunities page.

Presenting at Sin City Ruby 2024 High Performance PostgreSQL for Rails at Sin City Ruby 2024. Photo credit: Ernesto.

Rideshare and Book Sales

By using queries and examples from Rideshare, it was a nice way to promote the app, which I hope is useful even without buying the book.

We got a little spike of around 20 book sales over the couple of days of the conference. Hopefully folks took advantage of the SinCityPostgreSQL discount code for 35% off.

Follow-on Questions

I was very perceptive to the kinds of questions or observations that Ruby developers might have about PostgreSQL topics. A large emphasis of my book is to help raise awareness of the amazing capabilities that PostgreSQL has that might not be known in the Ruby and Rails communities.

I jotted down some of those topics in a tweet, and you can expect a future post that focuses on these. Some of the topics that were new were “covering” indexes, when to sort data in queries and indexes, and how to view pages or buffers that are accessed for a query.

🏜️ Hanging Out

The day before the conference Vladimir rented a car from the airport and drove us out to the Hoover Dam area. We stopped in the nearby town and had coffee. I hadn’t been outside the “Strip” area, so it was cool to spend time with conference friends and see a bit more of the desert landscape.

Presenting at Sin City Ruby 2024 Exploring old train cars: Andrew, Dominic, Jeremy, Vladimir (not pictured: Irina). Sin City Ruby 2024. Photo credit: Irina.

Presenting at Sin City Ruby 2024 Exploring Hoover Dam tunnels: Andrew and Dominic. Photo credit: Irina.

Thanks

I really enjoyed the conference and thanks again to Jason Swett for organizing it. I appreciate all the feedback on the presentation from the attendees. Please get in touch if I can help out with anything else, or if you have additional feedback.

Until next time.