What comes in mind when one think about optimization of SQL queries!
Basically it requires the skills and resources to write queries on big size database or data warehouses.
Why even sometimes optimization is leading challenge???
Let's dive into the core of optimization and see what we got there!
If I am writing a select query to the server where multiple tables are involved so basically queries depends on the IO cost as well as the transformation operators applied to the raw data or if aggregation is involved. Sometime simple select query like fetch top 100 record from the table, people trying to optimize it. But that's not the issue actually.
Problem arises when multiple technologies are connected to database and same time everyone needs efficiency so what should the optimal use to pull data. Let's try to understand with an example:
Let say I have an regular API post request to the database table for filling out my orders or let say any transactional data, in such case, if other select queries are also fired on the table then obviously there could be some lagging while pulling data from the table and at this time SQL optimization for your queries should work.
Some general tips tricks included:
1) make sure columnstored indexes are applied to columns generally went for aggregation
2) non clustered indexes if available must be taken care of while writing queries l, most of time engine even don't use the index, so With_index() hint is better to use.
3) scalar UDF inside select statement would be better then choosing function in. Where clause, so better to apply derived table concept or cte's.
4) join order as well as right joins should be selected.
5) choosing of set operators to filter content could be better.
Comments
Post a Comment