Create index on a column with only 2 distinct values

Viewed 1185

I have a table with millions of records.

One of the column has only 2 values '0' and '1'.

I am only concerned about the records where the column value is '0' and do some processing off of those records.

Considering the number of records containing value '0' will be around in the hundreds would it be wise to create an index on that column.

Since then the index will just have 2 values '0' with hundreds of refrences to the actual records and '1' with references to its cooresponding millions of records.

Here since I dont care about '1' and its references, should I be using an index in the first place?

2 Answers
CREATE TABLE Detalii_Meciuri(
    DetaliiID int not null primary key identity(1,1),
    MeciID int FOREIGN KEY (MeciID)
    REFERENCES Meciuri(MeciID),
    Categoria_1 int not null check (Categoria_1 = 0 or Categoria_1 = 1) ,
    Categoria_2 int not null check (Categoria_2 = 0 or Categoria_2 = 1) ,
    Categoria_3 int not null check (Categoria_3 = 0 or Categoria_3 = 1) ,
    Categoria_4 int not null check (Categoria_4 = 0 or Categoria_4 = 1) ,
    Categoria_5 int not null check (Categoria_5 = 0 or Categoria_5 = 1) ,
    Puncte_Echipa_A int not null check (Puncte_Echipa_A > 0),
    Puncte_Echipa_B int not null check (Puncte_Echipa_B > 0),
);
Related