how to set the right index(es) for this schema ?
I have a product table where I show at first active products like this:
SELECT name, price, categoryid FROM products WHERE status = 1;
Then a people can filter like price then I do this:
SELECT name, price FROM products WHERE price > 100 AND status = 1;
But another want to filter like price and category then I do this:
SELECT name, price, categoryid FROM products WHERE price > 100 AND categoryid = 4 AND status = 1
Now how can I set right index and noncluster/filtered index ?
At now I have done this:
CREATE INDEX I_PRODUCT_ACTIVE_NONC ON product(categoryid) WHERE status = 1;
Then I have think about this when he want to filter both:
CREATE INDEX I_PRODUCT_ACTIVE_NONC_FILTER ON product(price, categoryid) WHERE status = 1;
But when he want to filter only price then this is effective:
CREATE INDEX I_PRODUCT_ACTIVE_NONC_FILTER ON product(price) WHERE status = 1;
So how many index should I create for this example and it is okey to have many filtered indexes or it is bad ? because I have ohter columns like color and size, this has be indexed too.
Any expert can help me what I should have to do ?