I have a very long query which return some records if the column id_cat matches user search.
It looks like this:
SELECT *
FROM table
WHERE (id_cat = 50 OR id_cat = 51 OR id_cat = 52...) up to some high numbers.
In above case the query gets real big which increases it time for response.
I need to optimize that because response time get close to 15 seconds (basically it search through all of the categories).
How should I do this?
First of all i was thinking of building a query like below:
SELECT * FROM table WHERE (id_cat = (50 OR = 51 OR = 52))
Which should decrease the number of sql words but it doesnt work like this (returns null instead of rows). And I dont have any more ideas.
Do you have any suggestions about how to handle that?