we have a table with 2 million records with PK userid and not unique field “Company” we have 35,000 select query an hour to check if a userid exists in our db and what companies he is related to.
should we run the high amount of query on the main table or should we create a view with only userID and company fields and run the query against it?
what are the upside and downside?
i will appreciate your help!
P.s
the 35,000 queries an hour are with random userid, and change every time.
the user id and company are not updated but we add about 20,000 new rows a day.
my major concern is minimize the response time of the selects even if i do updates to other fields of the table.
Creating a VIEW will not help. It will simply reference the underlying table every time you use it.
What might help is to create a covering index on the columns you query. Assuming you only need UserID and Company:
Now, queries of the form
can be satisfied from the index without reference to the table data. This will probably improve your performance (on SELECTs).