| От | Tom Lane |
|---|---|
| Тема | Re: Indexing a Boolean or Null column? |
| Дата | |
| Msg-id | 17336.1073190412@sss.pgh.pa.us обсуждение |
| Ответ на | Indexing a Boolean or Null column? ("D. Dante Lorenso" <dante@lorenso.com>) |
| Список | pgsql-performance |
"D. Dante Lorenso" <dante@lorenso.com> writes:
> Does it make sense to have an index on data_is_active?
Hard to say. You weren't very clear about what fraction of the table
rows you expect to have data_is_active = true. If that's a very small
fraction, then an index might be worthwhile.
However, I'd suggest using a partial index that merges the is_active
test with some other useful behavior. For example, if this is a
common pattern:
> SELECT *
> FROM table
> WHERE data_lookup_key = 'pear'
> AND data_is_active IS TRUE;
then what you really want is
CREATE INDEX myindex ON table (data_lookup_key) WHERE data_is_active IS TRUE;
> I bet this is in a FAQ somewhere. Can you point me in the right
> direction?
See the docs on partial indexes.
regards, tom lane
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера