I'm confused about how to chose best index for my table:
Have this table:
Hotel
-has_1
...
-has-5
-nota_AVG
-nota_1
-nota_2
-nota_3
and this
Nota_hotel
-nota_1
-nota_2
-nota_3
-id_hotel
Field with name "nota_*" from hotel is update from a trigger on table Nota_hotel and this field changed frequently.
My need do some query like
select * from hotel where has_X = true or has_Y=true order by nota_Z
where my clause "WHERE" can have 1 has_X or many has_* fields in query depend on what checkbox is selected.
I want know what is best practice to put index, add for every field "nota_" a index and for fields "has_" create a single index(has_1,...,has_5) or add for every field "has_" a index too, and if have this much index is possible to strangle my MySQL server ?
create table hotel(
id int primary key auto_increment,
nume varchar(255),
index hotel_nume_index(nume),
nume_oras varchar(100),
nume_zona varchar(100),
nume_tara varchar(100),
foreign key (nume_oras,nume_zona,nume_tara) references oras(nume,nume_zona,nume_tara) ON DELETE CASCADE,
descriere text,
stele int,
map_x double,
map_y double,
has_sauna TINYINT(1),
has_piscina TINYINT(1),
has_parcare TINYINT(1),
has_restaurant TINYINT(1),
has_fitness TINYINT(1),
distanta_obiectiv double,
code_api1 varchar(255),
code_api2 varchar(255),
code_api3 varchar(255),
intern TINYINT(1),
nota_hotel double,
nota_restaurant double,
nota_locatie double,
nota_conditii double,
nume_comision varchar(100),
foreign key (nume_comision) references comision(nume)
);
create table nota_hotel(
fb_id varchar(100),
data DATETIME,
nota_restaurant double,
nota_locatie double,
nota_conditi double,
comentariu text,
nume_user varchar(255),
id_hotel int,
foreign key (id_hotel) references hotel(id) ON DELETE CASCADE
);
Here is full definition