I would like to create an index, but ı have a problem. My field is very changeable. the quantity field represents the number of products and I should get greater than zero quantity. I wonder that When I create an Index with quantity, it is effective? Or I will happy when I hear your suggestions.
For Example, My query is:
SELECT productId
FROM Inventory
WHERE type=‘warehouse’ and warehouseId =1 and totalQuantity > 0
I guess my indexes could be either of one
-CREATE INDEX idx_inventory_qty
ON Inventory
(warehouseId
,productId
,type
) WHERE (0 < totalQuantity
)
or
-CREATE INDEX idx_inventory_qty
ON Inventory
(warehouseId
,productId
,type
,totalQuantity
)
or what’s your suggestions?