Slide 8
Slide 8 text
Index Types
• Balance-Tree (BTree)
• Default for pg
• balanced structure, good for most of cases (such as such as equality and ranges) and all data
types
• Partial
• add_index :statuses, :liked, name: "index_statuses_on_disliked", where: "(liked IS FALSE)”
• Faster since less storage is limited by where clause
• Commonly applied to boolean fields in where clause
• Expression
• Useful for queries that match some function of data such as case-insensitive match of login
email
• create index users_lower_email on users(lower(email))
• Multi-column
• Combining multiple columns (foo, bar), used for where foo = ‘fooz’ and bar = ‘baz'