Viking’s Weblog

November 3, 2009

A jackpot today (few intersting links)

Filed under: Technical Documentation — msrviking @ 8:55 AM

Hello folks,

I was going through my blog roll today and noticed some bunch of links thats woth to look at and well I say its a jackpot on what I was doing for some time.

1. Logical Query processing – this has been great area of interest for me for quite a long time, and Itzik has done a great job consolidating all this in a flow chart. It makes life easy for people who want to understand the logical flow of the operators for a query to be processed. Thanks to Itzik and Solidq for sharing this!

2.  SQL Server Error Logs – Although I am familiar of this topic, and know the in’s and out’s of how it works but never blogged. So thought of sharing this with you guys and thanks to Jeremiah putting it so clear and simple.

I hope you guys will enjoy reading the links.

Cheers!

http://facility9.com/2009/10/15/sql-server-error-logs

November 2, 2009

Timeout | Blocking | Wait types

Filed under: Performance tuning — msrviking @ 4:22 AM

I am into a performance analysis and tuning assignment wherein I need to identify a “mysterious” performance issue. Sounds familiar by words, “Yes” but its really difficult if one doesn’t know where to start (the state I am in the beginning of the exercise).  Well, all these aside, but here is the problem statement given by the team “We have timeouts and deadlocks happening”.

With this small and simple one liner I started thinking like this,

- What is a time out? I had to get back to basics  for this and per definition which I love to read again and again is

“Before executing a query, SQL Server estimates how much memory it needs to run and tries to reserve this amount of memory from the buffer pool. If the reservation succeeds the query is executed immediately. If there is not enough memory readily available from the buffer pool, then the query is put into a queue with a timeout value, where the timeout value is guided by the query cost. The basic rule is: higher the estimated cost is, larger the time out value is. When the waiting time of this query exceeds the timeout value, a time out error is thrown and the query is removed from the queue.”

Well keeping in this in mind, I went hunting for memory, CPU configuration of the box.

- What is the configuration of the RAM, CPU and how is it doing?

64G RAM, and 8 core machine is having time out and deadlocks. Wow! Can’t believe it and so I decided to go to the box and check it myself on how it is doing. To my surprise all looks fine (RAM and CPU) running below the threshold levels. So what is that I am hunting for?

Over years of experience gave me a gut feeling which is usually very close to solution or at least to the  problem to start with, in such confused state of mind.  So my gut feeling was saying all looks fine so what is bad going on here.  A strong thought – maybe processes are getting blocked, and all these processes are accessing same tables through different t-sql batch of statements (procedures, functions).

- Does blocking cause timeouts?

This was the first question I had with series of questions like if timeouts are happening why isn’t evident in CPU /RAM utilization. What is going wrong and where? These questions started haunting me which led me to these interesting links which I am consuming (may be 10th time) to understand what should be my next question.

Here are the links for you guys

http://www.informit.com/articles/article.aspx?p=686168

http://sqlserverpedia.com/wiki/Wait_Types

I am curently using these links to arrive at some information for analysis and tune the damn queries causing performance issue through blocking.

I shall keep you guys posted on how I progress, but remember yes blocking & wait type are related (although I didn’t mention about wait types explicitly in the post) and yes of course you have time outs because of blocking which I shall confirm it after this.

Maybe you guys know all these, and even I do but thought of blogging as my thoughts were flowing else I need to spend “regurgetating” you see ;) .

October 30, 2009

SQL Azure in. Is my job out?

Filed under: General — msrviking @ 3:19 AM

I have been mostly with database from the day one I had be in IT field. I worked on MS Access 97 to SQL Server 2008 until date, and wrote millions of lines of code, administered and managed databases in all environments, designed systems to provide availability, scalability and so on. So people know me as a database guy (not to boast about!) in my organization and a lighter side – my lunch box looks like a cylinder – pictorially as a database ;) so you know now what am I talking about.

All this is momentary where people look at me for any database stuff, but some kind people who really don’t know what I am thinking when all this said around, try testing me asking what will be state of your job if  SQL Azure is going to go full cylinders and we may have loss of business and that means my job is on stake in future.  This question was asked by one of my team mates (an application technical architect), and back was the answer from me spontaneously. I replied back – What does it matter? We (DB guys) shall upgrade our knowledge on technology but the base will remain same and here is what I meant to say the “base” – as long as I (DBA’s) know how to store data, query data and protect data come whatever technology it could be a easy job to catch with technology.

Similar thoughts are reflected in Buck’s post here. It’s very coincident and my thanks to Buck for helping me to think much clearer after reading this through. Do visit the post and feel comfortable about your future.

Enjoy!

DB Designing? Objective /Goal

Filed under: DBA Rant — msrviking @ 1:27 AM

One of my shop mate came up to me and said – “Hi! I did a database design for one of the projects. I need to set my goal so that my project supervisor assesses me at the end of the exercise.”!

Well, my first thoughts were like what is a non-db guy doing in a database design. I am definitely not comparing myself with him nor with anyone but it surprises me sometimes when a technical (especially application dev leads) go ahead and design tables. In my thoughts I definitely don’t have any aversion towards the apps team or “great” tech leads, but in my shop its like “I create the mess! and then someone reviews and fixes.” Somehow, I don’t always appreciate the idea of  having app team design database until and unless this guy is definitely lot experienced in db design along with application development. At the EOD, its we who (DB guys) clean up the created mess. Oh, I am cribbing a lot again and always I express all these over my posts but my intent is to convey what is good, what is bad in DB process.

After a little dodging from this guy I decided to put in thoughts over what he had asked (Goal at the end of the activity). I am going to put what I had shared with him, and I would want you guys too to share your thoughts.

All these are from years of experience, so feel free to comment.

- Understand requirements through case studies, prototypes, documentation

- Map the requirements per module to a specific subject area (application modules, reporting, archiving, auditing, and any other few non-functional requirements)

- Identify key entities with high level attributes and prepare a conceptual data model

- Transform a conceptual data model to an E-R diagram with entities, attributes (key & non-key), relationships (1:N, N:1, M:N)

- Transform a logical data model into 3NF (3rd normalized form)

- Walkthrough the business analysts, technical team (application development & DB team), business team through the data model

- Identify the gaps during the walkthrough sessions and make changes to logical data model accordingly

- Transform an evolving logical data model to physical data model

- Review physical data model with Database Administrator to identify the type of objects that needs to be created in the DB instance (tables, triggers, data types, constraints [unique, foreign key, null able], indexes)

- Provide scripts to Database Administrator for creating tables and other objects appropriately in the table

- Provide guidelines in the volumes of data that could be generated for each of the table and plan for storage along with the DBA

- Ensure the scripts provided for object creations are appropriate per understanding with the app team & DB team

- Evolve data model as when requirements keep changing (new /adding)

- Ensure that the data model conforms to normalization process per normalization rules

- Ensure that the data model is flexible for changes in future and is not rigid which would cause overhead in future

- Ensure the process of synchronizing between the logical data model, the physical data model and the physical objects are smooth

- Provide guidelines to the team on the use of the entities, attributes, relationships from a logical data model perspective

Cheers!

October 29, 2009

SQL Server DBA?

Filed under: DBA Rant — msrviking @ 4:05 AM

I had an assignment around 2 weeks ago which was one of the toughest I could list out. One of the client had performance issue in one of the boxes and weren’t able to identify what could be the cause of the issue.

Someone from the DBA Group (where I don’t belong) had been identified for working on this – Identify the problem & provide recommendations. I was asked to guide this gentleman while he is on the job! Well, it just happens sometimes that I have to spend my energy thinking for my own activities on my table and also for others. And this is part of my job and I definitely won’t gripe about it. I told myself  “I need to help this guy just the way I am going to help me”.

All was set right to take off, but the only thing which missed from the beginning until the end of the exercise was that the DBA was not communicating. I did follow ups, mails, calls (short guidance’s), visited workplace  of  the DBA checked if we were in right directions and so on. All effort was on, and finally after the results were obtained from the monitoring scripts, the analysis phase started off.  The same communication problem was still existing during this stage too, and I was not knowing at all of what was happening at the other end.

One fine evening I get a recommendation list to be evaluated and validate after a single line follow up. The next day I spent 3 hours trying to collate information after large logs and trying validate. In vain!, I couldn’t complete and the presentation was scheduled the next day :o .  I gave up at the end giving my high level thoughts and as expected all these backfired where the client wasn’t happy with what was done.

And then one day I was asked to understand everything, analyze, recommend and present my findings. It was hell-of-days (5 days continuously) running through large logs (> 1.5 G), traces, performance counters and trying tie several pieces of information. A crazy time but I didn’t crib at all. At the end I could present findings and recommendations and I could save the face of the activity called as “DB Performance Analysis”. But one learning – Be whatever you are (multi-certified, well recognized), but things wouldn’t work if you don’t communicate. Communication is so important for any activity in life (work /personal). So guys if you such kind of situation I would say to help the other guy in communicating else you will be stuck as I was.

I hope this experience of mine helps anyone else out there.

Cheers!


Reports subscription in SSRS 2008

Filed under: Configuration — msrviking @ 2:14 AM

I had a request from my clients asking “Can a user subscribe to reports all by his own?”. The quick answer I said “Yes”, and I did a POC to find how it could be done and what are the limitations.

After the POC I decided to document which I shared with the client team. I thought I should share with you all on what it is all about! Although the content isn’t exhaustive but probably could help for a initial startup.

/**************************************************************************************/

Scheduling a report in Report Server (SSRS 2008)

Subscription:

A subscription of a report is an on-demand reporting which could be scheduled and the delivery of the report can be automated. A subscription is processed in the report server and the delivered report can be shared in a folder of a file server of can be sent to email addresses.

A subscribed report uses stored credentials, and the user wanting to create subscription should have permission to view the report and also creating individual subscriptions. As part of configuration at reporting server level, scheduled events and report delivery (e-mail delivery should be configured separately) should be enabled. Additional delivery extensions can also be added by installing developed custom extensions.

Types of subscriptions:

-          Standard subscriptions are created and managed by individual users. A standard subscription consists of static values that cannot be varied during subscription processing. For each standard subscription, there is exactly one set of report presentation options, delivery options, and report parameters.

-          Data-driven subscriptions get subscription information at run time by querying an external data source that provides values used to specify a recipient, report parameters, or application format. These types of subscriptions are typically created and managed by Report Server administrators.

The limitations of using data-driven subscriptions are as following,

  • Data-driven subscription functionality is not available in Standard Edition.
  • For subscription data, choose a data source that can provide schema information to the report server. The supported data source types include SQL Server, Oracle, Analysis Services databases, SQL Server Integration Services package data, ODBC data sources, and OLE DB data sources.

Permissions for subscriptions:

Users can subscribe to reports through two tasks described as below.

-          The “Manage individual subscriptions” tasks will allow creating, modifying, and deleting subscriptions that are owned by a user for a specific report. This task is part of the Browser and Report builder predefined roles. Any user assigned to these roles having the above task will the user to manage only those subscriptions that are owned.

-          The other task will allows users to access and modify all subscriptions is “Manage all subscriptions”. This task is for data-driven subscriptions and is part of the predefined role – Content Manager.

Creating standard subscription:

A standard subscription can be created by individual users who want to have a report delivered through e-mail or to a shared folder. A standard subscription is always defined through the report on which it is based.  A user who creates a subscription owns that subscription. Each user can modify or delete the subscriptions that he or she owns.

Pre-requisites /Limitations of Standard subscription

Requirement 1

Permission to view the report which is chosen for subscription, which would mean the user, should be assigned to the role “Manage individual subscriptions”.

Requirement 2

The report must use stored credentials or no credentials to retrieve data at run time. A report can’t be subscribed which is configured to use the impersonated or delegated credentials of the current user to connect to an external data source. The stored credentials can be a Windows account or a database user account.

Requirement 3

If the model is used as a data source for a report contain security settings then this report can’t be subscribed.

Requirement 4

If the report requires a parameter to run during the processing time then the input parameter should be defined while scheduling the subscription.

Subscription creation

Once the subscription is created, a SQL Agent job with a system id is created with particulars like

-          Job name

-          Job description

-          Job schedule (day, hour, frequency)

-          Job running account – Local Service

-          Transact SQL referring to an event which will trigger the schedule process

When the job runs successfully an e-mail is sent and /or the scheduled report is put in the shared folder of the file server for later access.

Other details:

Subscriptions to reports create specific schedules that are defined through subscription properties, but shared schedules are easier to manage and maintain for the following reasons:

  • Shared schedules can be managed from a central location, making it easier to compare schedule properties, adjust frequencies and recurrence patterns.
  • If shared schedules are used, when scheduled operations occur is precisely known. This makes it easier to anticipate and accommodate server loads before performance issues occur.

/**************************************************************************************/

Let me know what you guys think?

Cheers!

 

October 28, 2009

Trace skipped records – SQL Server profiler

Filed under: Performance tuning — msrviking @ 11:22 PM

Recently I was working on performance analysis of a “mystery monster” stored procedure in one of the projects at my shop. I was working on this stored procedure in the usual way I try to pick up pain points of stored procedurs /sql statements. And I decided to run SQL Server profiler to profile the performance of the stored procedure. All was done and profiler ran fine and I could see lot of information captured although not overwhelming. I took a deep breath to understand 2000 lines of profiled data, and as I was scanning through I saw something like this and have never seen it before.

Here is the snapshot which I had in the profiler,

 

Trace Skipped records

Profiler results

 

I thought this is something new which I haven’t seen before and took it as learning (partly ignorance too :( ).  But, it is so coincident that someone, somewhere had the same problem and this is what I appreciate about sharing information across the globe.  That someone is ScaryDBA  who had the same issue, but he went and dug around on to see what is this all about?  Well here is what he had to say in his blog post – Snags with Profiler GUI.

Learnings – Don’t be ignorant like me and dig around if you find something new else it will be half-knowledge.

Thanks to ScaryDBA for his thoughts!

Enjoy.

 

Free SQL Server tutorial

Filed under: Training — msrviking @ 10:57 PM

I am sure whoever are reading my blog do know about SQL Server well. However, I am sure there will be newbie’s around who will want to kick-start off on SQL Server and for them for others too (including me), it makes worthwhile to read and learn the content from this website http://midnightdba.itbookworm.com/.

Thanks to Sean!

Enjoy!

Ctrl+Shift+M – SQL template

Filed under: Tips & Tricks — msrviking @ 10:53 PM

I was doing a regular reading through my favorite blogs and I learnt something new early in the morning. Here is what it is all about.

Being on development side of the applications I always recommend developers, leads and everyone who wants to write t-sql code to use standard templates. How could we achieve this quickly?

On opening your SSMS instead of a blank window, you could get your template by using Ctrl+Shift+M, and you could customize your template by replacing the content in the file or replacing the file itself but with same name in the following path

C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql

The file you will want to edit to standardize the template will be Sqlfile.SQL.

I got this tip from my Buck Woody. Thanks Buck for sharing info on such small but important things.

Enjoy!

September 25, 2009

Performance analysis methodology

Filed under: Performance tuning — msrviking @ 2:14 AM

Hello Guys,

Few months ago I had worked on performance analysis of database that needs to be upgraded from SQL Server 2000 to SQL Server 2008. Before doing the analysis, and providing recomemndations I thought I will document the methodology and share with the project team. As an effect of this thought I had prepare this methodology.

Start of the document:

Performance Issues – Database upgrade from SQL Server 2000 (32 bit) to SQL Server 2008 (64 bit)

Overall databases performance

Since, the source databases are moved from the existing system (SQL Server 2000 – 32 bit environment) to the destination system (SQL Server 2008 – 64 bit environment), the overall database performance would improve for the reasons that SQL Server 2008 has improvised database engine and the instance would be hosted on the 64 bit environment.

However there could be stored procedures, user defined functions, triggers and other database objects which may degrade performance after the upgrade because of the following reasons.

-          Query engine interpretation of execution plans in SQL Server 2008 is different to that of SQL Server 2000.

-          Statistics on columns and indexes will not be affective for query optimizer to prepare optimal plans.

-          Row counts or page counts will be inconsistent and /or incorrect.

To ensure that there is no performance issues due to upgrade, baseline performance will be identified for stored procedures, user defined functions, and also post-upgrade activities will be considered post the production deployment.

Poorly performing existing stored procedures

The identified poor performing stored procedures could have improvements in performance because of the improvised database engine features of SQL Server 2008 and higher processing power (64 bit) on which SQL Server will be hosted.

But the performance could be still not per existing environment because of the following reasons:

  • Poorly written queries.
  • Highly complex T-SQL logic.

Assessment

Overall databases performance

The process of measuring the current performance will be to obtain a performance baseline, and this baseline will provide statistics of current usage pattern of the stored procedures, user defined functions and will also give a reference for the future statistics.

  1. The performance baseline information will be collected after running traces. The traces will have to be created in the identified baseline environment, along with trace dependent physical tables and stored procedures for the traces to run. Essentially in short these will be the components for the traces to be run
  • Stored Procedures which will create, start, stop and clear traces in the SQL Server instance
  • Physical Tables will consist of trace based information columns like events, data columns.
  1. The traces will be run on SQL Server 2000 in all databases before migration and on SQL Server 2008 after migration. The few options on where to run the traces could be run.
  • Running trace in production environment. This is the optimal environment, for the reason that the traces will return actual figures of what is happening in the production environment on the existing stored procedures, functions, and any other DML operations.
  • Running trace in pre-production, UAT or any environment which is closest to production environment. The closest to production environment means that the boxes should be similar with that of production boxes in terms of hardware configuration. Although there will not be enough load on the server to sense how the sp’s are doing while under load, but at least there will be good readings (Duration, CPU, RAM usage) that may be close to production box.

In order to simulate production environment load, have few users could access and test the application with multiple flows and scenarios. As an alternative to simulate load, a single flow /scenario could be executed to gather enough information for the trace. To compare the performance measurements after migration the same flow /scenarios should be followed.

To baseline pre-migration and post-migration performance information, the key parameters that will be captured for the events (SP start and SP end, SQL start and SQL end) would be

  • Database Name
  • Object Name
  • Duration (ms)
  • CPU (ms)
  • Logical Reads
  • Physical Reads

This information will be gathered in trace file format (*.trc) and saved into a folders. After the trace files are captured these will be saved into physical tables, and scripts will be run on the trace tables in order to retrieve the consolidated numbers on how many sp’s, function’s, trigger’s are called through the application, and also performance indicators (above mentioned parameters).

Poorly performing stored procedures

To identify the pain areas and to improve performance in these stored procedures, below information would be required,

-       Functionality of the stored procedures and how these sp’s are being used in the application.

-       The current issues that are causing performance bottlenecks.

-       SQL Server 2008 new features or the best practices that could be considered to fit into these sp’s.

And to gather the above information the below activities will be carried out.

-          Understand the functionality of the stored procedures.

-          Analyze and evaluate the current performance of the sp’s in SQL Server 2000 environment.

-          Identify the pain areas in the stored procedures.

-          Fix the pain areas with new features of SQL Server 2008 and with best practices.

Analysis and Findings

Overall databases performance

The below steps will be executed on the trace results that are gathered from the production environment to arrive at a baseline performance.

-       Load the trace files data of each database into physical tables.

-       Extract relevant SQL statements from “textdata” column of the trace table based on the event class 41, and 12. These events represent T-SQL event class and the events are SQL Batch Completed, SQL Stmt Completed.

-       Extract the object names from the exec statements (extracted from the above step).

-       For each object name the table will be queried on the “textdata” column to see where has the sp been called with the pattern “exec <objectname>” for the event class 41, and 12.

-       The event classes 41, 12 have very useful information like duration (ms), logical reads, physical writes and CPU (ms) for each exec statement.

The trace /profiler results may have captured only the sp’s that were being called by the application during the tracing period, and may not be all the n (total sp’s) in the database.

Poorly performing stored procedures

After understanding the functionality, analyzing and evaluating the stored procedures a list of few best practices and new features will be arrived at, and which could be implemented in the stored procedures for performance gains.

The below list of best practices and new features could be used for implementation.

Best Practices:

-          Use object owner against the objects used in the sp.

-          Temp tables to be replaced with table variables wherever applicable.

-          Use sp_executesql, and parameterized queries to avoid excessive recompilation.

-          Replace cursor with SET based operations.

-          Avoid use of SELECT INTO statements instead use INSERT INTO.

New Features of SQL Server 2008:

The below list gives description of the new features of SQL Server 2008, and where could these be used.

-          Common Table Expressions (CTE):

  1. As replacement for derived table.
  2. Replace table variables /temp tables.
  3. Avoid repeat of code /same query again.
  4. Hierarchical queries (recursive queries – calling query in a query).

-          Table Valued Parameters (TVP):

With TVP data can be passed around as a single variable. What this means is that if multiple records are saved, this can be done very easily in one procedure call.

This also can be done using an XML column or a delimited list, but the difference with a Table Valued Parameter is that a typed row set which can be used directly in an INSERT, SELECT, UPDATE statement, and any other statement that can take a row set. This means no shredding of XML or having a function to split delimited string. This essentially reduces the code, and gives flexibility of using typed data, that would mean reduced calls to the database from the DAL increasing the performance. However as it is indicative that there will be performance improvements but may not be possible to implement for the reason there will be changes in the stored procedures and the code calling the sp’s (T-SQL or the C#).

-          CONVERT function:

The convert function helps in converting binary data to string characters in hex format directly.

-           GROUPING SETS:

  1. The Grouping Sets feature is really helpful when you want to generate a set of aggregate results and at the same time you want to group by varying columns.
  2. It is much easier to maintain and provides better performance when compared to running different queries against the same data and then finally performing a UNION ALL to get the desired results.
  3. It provides better performance as it is executes once against the data source.
  4. It is much easier to program and use Grouping Sets than writing multiple select statements.

-          Transact-SQL row constructors:

This feature doesn’t give performance improvement, but helps in code size reduction which would essentially mean the execution plan will be slim and easy for the query engine to interpret.

-          Compound Assignment Operator:

This feature essentially reduces the code content in a batch of T-SQL statements.

-           Sparse columns:

The sparse column is an ordinary column just like other columns but it reduces the storage requirement for null values. A nullable column can be made as sparse column by adding the SPARSE keyword when the table is created or altered. Once the column is a SPARSE column SQL Server will not allocate space for null values. Note that in using this feature it adds an overhead for data retrieval of non-null values. Therefore it is needed to carefully apply this feature for columns by calculating the space that can be saved. It is recommended to make the column a SPARSE column only if the space that could be saved is at least 20 to 40 percent.

-          Filtered indexes:

A Filtered Index is an optimized form of non clustered index. It is basically useful to cover those queries which return a small percentage of data from a well defined subset of data within a table.

Filtered Indexes is one of the greatest performance improvement introduced in SQL server 2008. A Filtered Index allows us to create a filter to index a subset of rows within a table. i.e., non clustered indexes can be created with a WHERE clause.

A very well designed filtered index will help improve query performance on very large tables; this will also generate a better execution plan as it will be much smaller than the full table non clustered index. It is more accurate than a full table non clustered index because it will only cover those rows available in the filtered index WHERE clause.

A Filtered index will help reduce the index maintenance costs as it is smaller and is maintained only when Data Manipulation Language (DML) statements affect the data in the index. It is better to have large number of filtered index, especially in scenarios when the data is known on which filtered index is created is changed very less frequently.  Similarly, if a filtered index contains only the frequently affected data, the smaller size of the filtered index reduces the cost of updating the statistics.

Another major advantage of creating a Filtered Index is that it will reduce the disk storage space for non clustered indexes when a full table index is not required. A full table scan can be replaced with multiple filtered indexes without significantly increasing the disk storage space for the indexes.

But to implement all these one needs to essentially understand the functionality of the column and indexes along with the execution plan.

-          MERGE statement:

The MERGE statement internally works as an individual insert, update and delete statement within a single Merge statement. The SOURCE and the TARGET table or query which should be joined together should be specified. Within the MERGE statement specify the type of the data modification that needs to be performed when the records between the source and target are matched and what actions needs to be performed when they are not matched. With the introduction of MERGE statement the complex TSQL codes which was used earlier to do checks for the existence or inexistence of data within the data warehouse can be replaced with single Merge statement. The use of Merge statement will also improve the query performance because MERGE Statement runs through data only once in the database which also improves performance.

-          Composable DML:

The OUTPUT operator works much like a “local trigger” on the current statement. The drawback is that there is no way to filter the returned result set directly. The OUTPUT data has to be inserted in a staging table and work from there.

With composable DML a statement of UPDATE, DELETE and even MERGE as a data source for your query can be used. This doesn’t give any performance improvements but will be useful for sp’s that use the functionality of OUTPUT clause, and this would be an advance feature.

-          Table hints:

The FORCESEEK table hint forces the query optimizer to use only an index seek operation as the access path to the data in the table or view referenced in the query. You can use this table hint to override the default plan chosen by the query optimizer to avoid performance issues caused by an inefficient query plan. For example, if a plan contains table or index scan operators, and the corresponding tables cause a high number of reads during the execution of the query, as observed in the STATISTICS IO output, forcing an index seek operation may yield better query performance. This is especially true when inaccurate cardinality or cost estimations cause the optimizer to favor scan operations at plan compilation time.

SQL Server query optimizer typically selects the best execution plan for a query, we recommend using hints only as a last resort by experienced developers and database administrators. Moreover this would involve analyzing the sp for statement level performance and judging if the FORCESEEK hint helps the sp or not will involve time and effort.

-          FOR XML PATH:

This feature doesn’t give any significant performance gain but would reduce the complexity of the code which uses FOR XML EXPLICIT to return XML data.

Fixing and Re-evaluation

Overall databases performance

The above information gives on how much time each sp is taking, how many CPU cycles is the sp taking, what are the logical reads, what are the physical writes. With this data as baseline per sp on each database, the performance will be evaluated of the same sp, by executing same exec statement (as it was captured from the production) on 64 bit SQL Server 2008 Enterprise (testing environment) against each database.

Any differences in performance based on the parameters of duration /logical reads would lead to evaluate on why there are performance difference with the issue based sp(s), and changes will be proposed to get the performance in line or get better in comparison with the existing production system. After the first iteration of proposed changes is implemented the stored procedures will be evaluated again for performance.

Poorly performing stored procedures

After the best practices and new features are implemented in the stored procedures, the sp’s will be evaluated for performance on the 64 bit SQL Server 2008 Enterprise (testing environment). In case there are any performance degradations in the sp’s due to changes, these will be analyzed for performance analysis and changes will be made followed by re-evaluation until performance reaches to acceptable levels.

End of the document:

Let me know what you guys think about all these!

Enjoy!

Older Posts »

Blog at WordPress.com.