Rails Postgres Partial Indexing
04-Feb-2021 1308
Postgres has a nice feature where you can index only the values you want to query on. Today I learned that Rails has a nice shortcut for taking advantage of said feature.While working on a new Box Out feature, I needed to query for graphics that have been shared on social media.I had a graphics table with a tweet_id column. I wanted to query for graphics that have been shared on twitter (aka tweet_id IS NOT NULL). The table is in the hundreds of thousands of rows, so I wanted to index tweet_id to help the query along. I was going to a plain old add_index. But then I remembered that you can do partial indexes.
Rails Postgres Partial Indexing #ruby #rubydeveloper #rubyonrails #Rails #Postgres #Partial #Indexing https://rubyonrails.ba/link/rails-postgres-partial-indexing