Indexing boolean fields

前端 未结 6 1391
-上瘾入骨i
-上瘾入骨i 2020-12-07 20:04

This is probably a really stupid question, but is there going to be much benefit in indexing a boolean field in a database table?

Given a common situation, like \"so

6条回答
  •  星月不相逢
    2020-12-07 20:37

    No.

    You index fields that are searched upon and have high selectivity/cardinality. A boolean field's cardinality is obliterated in nearly any table. If anything it will make your writes slower (by an oh so tiny amount).

    Maybe you would make it the first field in the clustered index if every query took into account soft deletes?

提交回复
热议问题