Index in mysql.
I have a table in mysql database which has a very large number of rows and can be expanded. Currently 300,000 rows and can reach million records in the future. users perform a searche on the table from a php page. I update it with new records once a week roughly and I also delete and add more records so it can reach very large number of records. Currently I am not using indexes and it is very slow when a search is made. I have a query that perform the search and it has a few conditions. I want to use indexes to optimise performance. below is the query style. I am just showing the structure using an example as the true values are not shown:
select value1, value2, value3,value4 from tablename where objectID like %searchstring%
If valuex == ‘x’
{sql = ‘AND valuex = $variablevalue’
else if valuey == y
{sql = ‘AND valuey = $variablevalue’
etc
To create an index would be on the where clause as the search is made on the objectID. correct?
but users can select other options from the drop down values as valuex or valuey. so what is the best way to create an index to speed up the sql search?
- As I will be updating the table once a week, how do i rebuild the indexes?
thanks in advance