Top Five PostgreSQL Surprises from Rails Devs | Andrew Atkinson

submited by
Style Pass
2024-07-02 14:30:09

At Sin City Ruby 2024 earlier this year, I presented a series of advanced PostgreSQL topics to Rails programmers. Afterwards, a number of people provided feedback on surprising or interesting things from the presentation.

Covering indexes add column data from two or more columns, supporting one or more queries. Having the column data predefined in an index can significantly reduce the query cost. PostgreSQL describes a covering index as:

In PostgreSQL we can create covering indexes using multicolumn indexes. Multicolumn indexes cover all of the columns needed for a query, meaning PostgreSQL could use an efficient index-only scan accessing the data using only the index.

From PostgreSQL 12, we gained an additional option to create covering indexes by using the INCLUDE keyword. How do we do that?

The idea for INCLUDE is to list columns that aren’t being filtered on, but are requested in the SELECT clause. Let’s look at an example.

Leave a Comment