Is there any performance gain in indexing a boolean field?

后端 未结 7 1865
独厮守ぢ
独厮守ぢ 2020-12-02 10:39

I\'m just about to write a query that includes a WHERE isok=1. As the name implies, isok is a boolean field (actually a TINYINT(1) UNSIGNED

7条回答
  •  星月不相逢
    2020-12-02 10:58

    No, usually not.

    You usually index fields for searching when they have high selectivity/cardinality. A boolean field's cardinality is very low in most tables. It would also make your writes fractionally slower.

提交回复
热议问题