SQL Optimization
1. Add where on your query
2. If you remove some data after the data return then remove the remove condition in the select statement where the clause
3. Most important is to Add an Index on the column where you use the where clause.
4. Remove multiple call databases from code and call once and find all data at once to reduce the number of roundtrips.
5. Remove the index on the temp table if the data is in limit.
6. Remove subquery use Join.
7. Remove the query that returns the subset of results, instead use a query that can return full results.