Skip to main content
thoughtbot thoughtbot
  • Live on Twitch!

    thoughtbot is livestreaming

    Work alongside the thoughtbot team as we collaborate with each other and our clients, live. Ask us anything, we're live right now!

  • Case Studies
  • Blog
  • Let’s Talk
Live on Twitch!

thoughtbot is livestreaming

Work alongside the thoughtbot team as we collaborate with each other and our clients, live. Ask us anything, we're live right now!

Let’s get started!
View all Services
Development
  • Ruby on Rails
  • Hotwire
  • AI and Machine Learning
  • Maintenance
  • Mobile
Design
  • Discovery Sprints
  • UX, UI, and Product Design
  • Design Systems
Product
  • MVP
  • Product Management
  • Accessibility
Team and Processes
  • Team Augmentation
  • Fractional Leadership
View all Services
View all Resources
Development
  • Tech Leadership Resources
  • Open Source
  • Books
  • The Bike Shed Podcast
  • Live Streaming on YouTube
  • Conference Talks
The business of great software
  • Playbook
  • Purpose Built
  • Giant Robots Smashing Into Other Giant Robots Podcast
  • Design Sprint Guide
  • Live Streaming on LinkedIn
View all Resources

SQL Articles

Written by thoughtbot, your expert partner for design and development.

    • All Topics
    • Design
    • Development
    • Product
    • More topics
  1. Sorting elegantly in Rails with in_order_of

    Sorting columns in custom order in Rails elegantly using inorderof.

    Trésor Bireke
    April 28, 2025
    • Ruby
    • Rails
    • SQL
    • Performance
    • Code
  2. Testing SQL queries in a Ruby service

    An epic journey of facing MSSQL and missing Rails.

    Sally Hall
    December 16, 2024
    • SQL
    • Testing
    • Stories
    • Ruby
    • Web
  3. Testing SQL Performance in PostgreSQL

    Measure query speed with Postgres’ EXPLAIN ANALYZE.

    Elisa Verna
    December 15, 2023
    • SQL
    • PostgreSQL
    • Performance
  4. Joining Postgres tables using arrays of IDs

    Some tips on how to do many-to-many SQL queries without a normal join table.

    Dave Iverson
    December 5, 2023
    • Databases
    • PostgreSQL
    • SQL
    • Prisma
    • Airtable
  5. 3 ways to model an associated collection in Rails

    A look at the Postgres array type and good old join tables, each with their advantages and disadvantages.

    Dimiter Petrov
    November 23, 2023
    • Rails
    • Databases
    • SQL
    • PostgreSQL
  6. Sharing Query Logic Within ActiveRecord Models

    Re-use collection query logic within model instances to avoid duplication and get the best performance.

    Chris Toomey
    November 22, 2023
    • Rails
    • SQL
    • Web
  7. Detect anomalies in user behavior using Rails and PostgreSQL

    You probably use some type of error monitoring software to notify you when an exception is raised in your application, but are you being notified when there is an anomaly in user behavior?

    Steve Polito
    September 29, 2022
    • PostgreSQL
    • SQL
    • Analytics
    • Rails
  8. Query by Duration in Active Record

    How do you even save a “duration”, let alone query for records by that value? It’s actually easier than you think.

    Steve Polito
    June 7, 2022
    • Rails
    • Databases
    • PostgreSQL
    • Active Record
    • SQL
  9. Choosing the right database index type

    A quick introduction to which database index types are right for the task at hand in Postgresql.

    Greg Fisher
    December 16, 2021
    • PostgreSQL
    • SQL
    • Databases
    • Performance
  10. Understanding SQL GROUP BY

    Finally, you too can understand how to use GROUP BY in your SQL queries.

    Edward Loveall
    February 17, 2021
    • SQL
  11. Sign up to receive a weekly recap from thoughtbot

    Looking for even more ways to stay connected?
    RSS feed icon Check out our feeds
1 2 3 Next › Last »

Footer

thoughtbot
  • Services
  • Case Studies
  • Resources
  • Let's Talk
  • Our Company
  • Careers
  • Purpose
  • Blog
  • Sponsor
  • Mastodon
  • Bluesky
  • GitHub
  • YouTube
  • Twitch
  • Feeds
© 2025 thoughtbot, inc.

The design of a robot and thoughtbot are registered trademarks of thoughtbot, inc.

  • US: +1 (877) 9-ROBOTS
  • UK: +44 (0)20 3807 0560
  • Beware of fraudulent thoughtbot job listings Learn more
  • Code of Conduct
  • Accessibility Statement
  • Privacy Policy