-3

Please I need help optimizing my database performance. I have done some profiling to see seek queries using BlitzCache script created by Brent Ozar. After executing the script, some number of queries was listed which I generated an execution plan which can be found on the following link. https://www.brentozar.com/pastetheplan/?id=H1FmJ9_Wi

the below query listed by BlitzCache:

(@_msparam_0 nvarchar(4000),@_msparam_1 nvarchar(4000),@_msparam_2 nvarchar(4000),@_msparam_3 nvarchar(4000),@_msparam_4 nvarchar(4000),@_msparam_5 nvarchar(4000),@_msparam_6 nvarchar(4000),@_msparam_7 nvarchar(4000))SELECT
tbl.name AS [Name],
SCHEMA_NAME(tbl.schema_id) AS [Schema],
'Server[@Name=' + quotename(CAST(
        serverproperty(N'Servername')
   AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' + quotename(tbl.name,'''') + ' and @Schema=' + quotename(SCHEMA_NAME(tbl.schema_id),'''') + ']' AS [Urn],

tbl.create_date AS [CreateDate], CAST(tbl.is_memory_optimized AS bit) AS [IsMemoryOptimized], CAST(CASE idx.type WHEN 5 THEN 1 ELSE 0 END AS bit) AS [HasClusteredColumnStoreIndex], CAST(tbl.is_remote_data_archive_enabled AS bit) AS [RemoteDataArchiveEnabled], tbl.temporal_type AS [TemporalType], CAST(CASE WHEN 'PS'=dsidx.type THEN 1 ELSE 0 END AS bit) AS [IsPartitioned], CAST(

    ISNULL((SELECT distinct 1 from sys.all_columns

    WHERE object_id = tbl.object_id

    AND is_sparse = 1), 0)

   AS bit) AS [HasSparseColumn],

CAST(tbl.is_node AS bit) AS [IsNode], CAST(tbl.is_edge AS bit) AS [IsEdge], CAST(ISNULL((select top 1 1 from sys.indexes ind where ind.object_id = tbl.object_id and ind.type > 1 and ind.is_hypothetical = 0 ), 0) AS bit) AS [HasNonClusteredIndex], CAST(CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [HasClusteredIndex], CAST(case idx.index_id when 1 then case when (idx.is_primary_key + 2*idx.is_unique_constraint = 1) then 1 else 0 end else 0 end AS bit) AS [HasPrimaryClusteredIndex], CAST(ISNULL((select top 1 1 from sys.indexes ind where ind.object_id = tbl.object_id and ind.type = 3 and ind.is_hypothetical = 0 ), 0) AS bit) AS [HasXmlIndex], CAST(ISNULL((select top 1 1 from sys.all_columns as clmns join sys.types as usrt on usrt.user_type_id = clmns.user_type_id where clmns.object_id = tbl.object_id and usrt.name = N'xml'), 0) AS bit) AS [HasXmlData], CAST(ISNULL((select top 1 1 from sys.all_columns as clmns join sys.types as usrt on usrt.user_type_id = clmns.user_type_id where clmns.object_id = tbl.object_id and usrt.name in (N'geometry', N'geography')), 0) AS bit) AS [HasSpatialData], CAST(ISNULL((select top 1 1 from sys.indexes ind where ind.object_id = tbl.object_id and ind.type = 6 and ind.is_hypothetical = 0 ), 0) AS bit) AS [HasNonClusteredColumnStoreIndex] FROM sys.tables AS tbl INNER JOIN sys.indexes AS idx ON

    idx.object_id = tbl.object_id and (idx.index_id < @_msparam_0  or (tbl.is_memory_optimized = 1 and idx.index_id = (select min(index_id) from sys.indexes where object_id = tbl.object_id)))


LEFT OUTER JOIN sys.data_spaces AS dsidx ON dsidx.data_space_id = idx.data_space_id WHERE (CAST(

case

when tbl.is_ms_shipped = 1 then 1

when (

    select 

        major_id 

    from 

        sys.extended_properties 

    where 

        major_id = tbl.object_id and 

        minor_id = 0 and 

        class = 1 and 

        name = N'microsoft_database_tools_support') 

    is not null then 1

else 0

end

         AS bit)=@_msparam_1 and tbl.is_filetable=@_msparam_2 and CAST(tbl.is_memory_optimized AS bit)=@_msparam_3 and tbl.temporal_type=@_msparam_4 and CAST(tbl.is_external AS bit)=@_msparam_5 and CAST(tbl.is_node AS bit)=@_msparam_6 and CAST(tbl.is_edge AS bit)=@_msparam_7)

Dan Guzman
  • 28,989
  • 2
  • 46
  • 71

1 Answers1

1

Two quick guesses based on the information you provided in your question:

  1. Your SQL Server instance is not yet productive and sp_BlitzCache is showing internal statements that are "slow", because they are the only statements currently running. ==> This is possibly a non-issue.

  2. Your SQL Server instance is productive and the statement shown in the results of sp_BlitzCache is at the top. ==> This could mean that your productive databases aren't being used a lot. ==> See General Considerations further down.

  3. You seem to be having a general issue with your SQL Server instance. Consider using sp_Blitz to see if your SQL Server instance is configured correctly. This will return a prioritised list of items to check.

General Considerations

  1. Is your SQL Server instance a stand-alone instance or is it competing with resources from applications running on the same server? It is running on a server, isn't it? And it isn't running on a Domain Server, right?

  2. Does your Windows Server have enough RAM? Is your SQL Server instance's max server memory (MB) configured to allow for enough database pages to be cached in memory? Maximum server memory (duplicate)

  3. Is your SQL Server instance running on a supported version of SQL Server? (Service Packs, Cummulative Updates, ...)

  4. Is the network connection sufficient enough to support the amount of queries you are expecting? Are you possibly having network issues?

  5. If you check the wait statistics of your SQL Server instance for an hour using the script provided in the Blog Post Capturing wait statistics for a period of time (SQLskills.com / Paul Randal), what are the most prevalent wait types in your SQL Server instance? Check SQL Server Wait Types Library (SQLSkills.com / Paul Randal) for possible solutions.

  6. Consider engaging a consultant to analyse your server/instance/environment.

There are multitude of possible causes for performance issues, but without more details, the community will not be able to provide a solution.

Good luck.

John K. N.
  • 18,854
  • 14
  • 56
  • 117