- Main Topic 1
- use indexing
-
best
- Don't use "SELECT*" in a SQL query
- Avoid unnecessary columns in the SELECT list and unnecessary tables in join conditions
-
Do not use the COUNT() aggregate in a subquery to do an existence check
- use exist
- Try to avoid joining between two types of columns
-
Try to avoid deadlocks
- Always access tables in the same order in all your Stored Procedures and triggers consistently
- Keep your transactions as short as possible. Touch as few data as possible during a transaction
- Never, ever wait for user input in the middle of a transaction
-
Write TSQL using "Set based approach" rather than "Procedural approach"
-
How can we get rid of "Procedural SQL"? Follow these simple tricks:
- Use inline sub queries to replace User Defined Functions.
- Use correlated sub queries to replace Cursor based code.
- If procedural coding is really necessary, at least, use a table variable instead of a cursor to navigate and process the result set
- Try not to use COUNT(*) to obtain the record count in a table
- Try to avoid dynamic SQL
- Try to avoid the use of temporary tables
- Instead of LIKE search, use full text search for searching textual data
- Try to use UNION to implement an "OR" operation
- Implement a lazy loading strategy for large objects
- Use VARCHAR(MAX), VARBINARY(MAX), and NVARCHAR(MAX)
- Implement the following good practices in User Defined Functions
- Implement the following good practices in Stored Procedures
- Implement the following good practices in Triggers
- Implement the following good practices in Views
- Implement the following good practices in Transactions
-
subquery
- nested
- Correlated