4 ms·
Summary: if you have an index on a column which is mostly NULL, consider using a partial index covering only the records where it's non-NULL.
by mjw1007 6y ago
Summary: if you have an index on a column which is mostly NULL, consider using a partial index covering only the records where it's non-NULL.
- latch 6y agoAnother benefit of partial indexes is to limit a unique constraint: create index users_email on users(email) where status != 'delete'
- SomeHacker44 6y agoBe very careful, then, as the optimizer will (usually?) not use the index if the condition is not part if the query.
- jackTheMan 6y agoyou can create views for that, then it will be always part of the query.
- cakoose 6y agoThat's the part they sold in the title, but there's a bunch of other useful stuff for someone operating Postgres in production, something I'll need to do in a few months.