Skip to main content

Posts

Showing posts from December, 2023

Error Escalation and it's cure

 Error Escalation In SQL Server: What is Error Escalation? In DBMS, error could stand on multiple levels, let say database storage level(file path missing, change in disk, corrupt files etc), server connectivity error ( wrong instance connection, unauthorised access error, restricted users activity error), table level or data level error( data truncation, mismatch data type, out of storage etc). These are some common error which by default occurs and must be rectified after receiving it. But some database error that are cause by the queries written on the database could be recognised before execution and proper solution can be created in order to get rid of the error in the runtime of query. Let's understand the topic with an example: If say, the dynamic query is written for checking the existence of any object where object name is the user parameter, in such case may be user provide an input with symbols or keyboard characters which can cause the error, so here we will see how err...

Joins Optimization In SQL server

  What are Joins In SQL ? Joins are command used to combine two or more dataset, horizontally. The dataset may have a relationship between them or not, still joins work. If primary key and foreign key relationship exist then the output result is under refrential integrity and ine can rely on final output. Otherwise the final joined output is not reliable. JOINS Optimization: 1) always choose inner and outer join wisely, inner join result less rows then outer joins in most cases, so it also results faster. 2) use of join hint i.e. Merge, Nested or Hash should be used wisely, for coming to an conclusive execution plan. 3) use of index on the column in where clause as well as the column on which joins are performed is again improving performance. 4) writing joins with nolock hint is better approach. 5) updating statistics of the tables, before running joins queries is better approach. These are the some common practices one can used, beyond that SQL profiler Is always a better option ...