SQL Server 2012 :: Query Tuning With Each Run Of Fresh / Blank CACHE

Jun 4, 2015

I am using SQL Server 2012 Express.

I am doing performance tuning of SP/Query in Dev-Test environment.

I found that SQL Server caches plan between successive executions.

So if I test/execute SP 10 times, after 1st or 2nd execution, SQL server will pull-up plan-info from CACHE...Not from SQL SERVER Or Database...

Means i am not getting correct answer...

I found this 2 commands:

DBCC FREEPROCCACHE

DBCC DROPCLEANBUFFERS

But they say that executing above command might interfere/bother other people executing other query/sp on this server.

They also say that: Freeing the plan cache causes, for example, a stored procedure to be recompiled instead of reused from the cache. This can cause a sudden, temporary decrease in query performance.

Part of query was using Dynamic-SQL executed with EXEC command.

I replaced that with SP_EXECUTESQL.

How can I start testing of each SP-run with Fresh/Blank CACHE ?

View 1 Replies


ADVERTISEMENT

SQL 2012 :: Table Scan In Query Tuning

Mar 21, 2014

I am doing sp tuning. It has several lines. SO I divided into several small queries and executed individually and check the execution plans. In one small query, I found table scan is happening. That query is basically retrieving all columns from a table but the table doesn't have any pk or Indexes. So is it better to create non-clustered index to remove table sca.

View 2 Replies View Related

SQL 2012 :: Query Notifications For More Than Just Cache?

Jan 13, 2015

All the recommendations I see from Microsoft docs is to limit the use of Query Notifications (QNs) to notifying connected clients when changes to mostly-static reference or configuration data occur, and to keep the number of overall query forms in play and connected clients to a minimum. Any way regarding a more integral use of QNs and Service Broker from a web app to notify n-web servers (farm) of an update to data that could be updated concurrently and quite frequently, or with a system where the technique is used extensively with lots of different query forms?

View 0 Replies View Related

SQL 2012 :: Buffer Cache And PLE (Page Life Expectancy) Query

Aug 17, 2015

I'm getting an alert which states that both my Buffer Cache Hit Ratio and PLE are low on one of my SQL Servers though I'm not sure how to correctly check this.

I ran:

SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Buffer Manager%'
AND [counter_name] = 'Buffer cache hit ratio'

Which gives me the Buffer Cache Hit Ratio, cntr_Value of 9 though its constantly dipping between 3-3000 and is never steady and I'm unsure if this is normal.

I also ran:

SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Buffer Manager%'
AND [counter_name] = 'Page life expectancy'

Which gives me the Page life expectancy of 209061.

If these values would cause concern and if this is a normal Buffer Cache Hit Ratio? It's constantly dropping from high or low from what I can see. These scripts were pulled from another forum and I'm assuming they're showing the correct values.

View 1 Replies View Related

Query Tuning And Stored Procedure Tuning

Nov 22, 2000

Hi

Is there any good books for Query Tuning and Stored procedure Tuning

Thanks

View 1 Replies View Related

I Need Fresh Eyes On A Simple Sql Query

Apr 20, 2006

greets, im coding a few queries to a table. im storing sets of records into the table, each set of records will haev a different batch id. so basically 2 sets of records can occupy this table at the same time, and their batch id is the main key (with 2 other fields also being PKs). i want to compare the 2 sets in the same table and get the differences:
1. records that were added
2. records that were updated
3. records that were deleted

ive written queries for the added records, and the updated records but i cant get the query for finding deleted records. the logic looks good to me but im obviously missing something so i could use a fresh pair of eyes.
here is the table def:

Code:


CREATE TABLE [dbo].[UPCXREF_BATCH] (
[BATCH_ID] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[CHAIN_CODE] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[UPC] [char] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[ITM_CODE] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ITM_CATEGORY] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CREATE_DATE] [datetime] NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[UPCXREF_BATCH] WITH NOCHECK ADD
CONSTRAINT [PK_UPCXREF_BATCH] PRIMARY KEY CLUSTERED
(
[BATCH_ID],
[CHAIN_CODE],
[UPC]
) ON [PRIMARY]
GO



and here are the queries ive gotten so far

Code:


/* This section retrieves all UPDATED records */
SELECT 'U' as FLAG, b2.CHAIN_CODE as CHAIN_CODE, b2.UPC, b2.ITM_CODE, b2.ITM_CATEGORY
FROM UPCXREF_BATCH b2 INNER JOIN UPCXREF_BATCH b1
ON b2.CHAIN_CODE=b1.CHAIN_CODE
AND b2.UPC=b1.UPC
AND (b2.ITM_CODE<>b1.ITM_CODE OR b2.ITM_CATEGORY <> b1.ITM_CATEGORY )
WHERE b2.BATCH_ID='BTC0002' AND b1.BATCH_ID='BTC0001'



/* This section retrieves all NEW records */

SELECT 'A' as FLAG, CHAIN_CODE, UPC, ITM_CODE, ITM_CATEGORY
FROM UPCXREF_BATCH
WHERE BATCH_ID='BTC0002'
AND (CHAIN_CODE NOT IN (SELECT CHAIN_CODE FROM UPCXREF_BATCH WHERE BATCH_ID='BTC0001')
OR UPC NOT IN (SELECT UPC FROM UPCXREF_BATCH WHERE BATCH_ID='BTC0001'))




here was my attempt to get deleted records which looks like it makes sense but isnt working

Code:


SELECT 'D' as FLAG, CHAIN_CODE, UPC, ITM_CODE, ITM_CATEGORY
FROM UPCXREF_BATCH
WHERE BATCH_ID='BTC0001'
AND CHAIN_CODE NOT IN (SELECT CHAIN_CODE FROM UPCXREF_BATCH WHERE BATCH_ID='BTC0002')
AND UPC NOT IN (SELECT UPC FROM UPCXREF_BATCH WHERE BATCH_ID='BTC0002')



here batch 'BTC0001' is the older set of records that already existed and batch 'BTC0002' is the new set we just inserted into the table. am i missing something else?

View 11 Replies View Related

Incorrect Query Results, Could Use Fresh Eyes

Jun 4, 2007

I have three tables:

Category: category id, category name, more…
Topic: topic id, topic name, category id, more…
Post: post id, post text, topic id, more…

I need help with a query to display the following:

Category name, # of topics, # of posts

Example:
Category.........................Topics.....Posts
SQL Stored Procedures.........12........562


It’s coming along but there are some problems, ASP.NET actually has 2 posts not 1. And the java totals are correct but it should be Java, 3, 10 (all in one line)
Category.....Topics...Posts
ASP.NET.........2........1
C#................1........1
Java..............1........1
Java..............1........2
Java..............1........7


Overview: use category id to get count of topics then use the topic id to get the count of posts.


SELECT C.CategoryName, T.ThreadCount AS Threads, T.PostCount AS Posts
FROM Category AS C LEFT OUTER JOIN
(SELECT tt.CategoryID, PostID.PostCount, COUNT(tt.ThreadName) AS ThreadCount
FROM Thread AS tt LEFT OUTER JOIN
(SELECT ThreadID, COUNT(PostID) AS PostCount
FROM Post AS P
GROUP BY ThreadID) AS PostID
ON tt.ThreadID = PostID.ThreadID
GROUP BY tt.CategoryID, PostID.PostCount) AS T
ON C.CategoryID = T.CategoryID
WHERE (C.CategoryID = T.CategoryID)
GROUP BY C.CategoryName, T.ThreadCount, T.PostCount
ORDER BY C.CategoryName

Thanks in advance

View 6 Replies View Related

Sys.dm_os_memory_cache_counters Vs. SQL Server:Plan Cache Cache

Feb 15, 2008

Hi guys,

I am looking at the plan caches/cached pages from the perspective of
sys.dm_os_memory_cache_counters and sql serverlan Cache - Cache Pages

For the first one I am using

select (sum(single_pages_kb) + sum(multi_pages_kb) )
from sys.dm_os_memory_cache_counters
where type = 'CACHESTORE_SQLCP' or type = 'CACHESTORE_OBJCP'
a slight change from a query in
http://blogs.msdn.com/sqlprogrammability/

For the second just perfmon.

The first one gives me a count of about 670,000 pages only for the object and query cache and the second one gives me a total of about 100,000 pages for five type of caches including object and query.

If I am using the query from http://blogs.msdn.com/sqlprogrammability/ to determin the plan cache size

select (sum(single_pages_kb) + sum(multi_pages_kb) ) * 8 / (1024.0 * 1024.0) as plan_cache_in_GB
from sys.dm_os_memory_cache_counters
where type = 'CACHESTORE_SQLCP' or type = 'CACHESTORE_OBJCP'

it gives me about 5 GB when in fact my SQL Server it can access only max 2GB with Total and Target Server Memory at about 1.5 GB.

Does anyone have any idea what is going on?

View 2 Replies View Related

Fresh Installation Of Sql Server 200 Enterprise

Oct 24, 2007

Can anybody provide me with the guidelines to install a fresh copy of SQL Server 2000 Enterprise Edition? The previous installation included a system account and it was on the same drive as the operating system. I remember reading this was not a good practice. Am I wrong?
thanks in advance

View 1 Replies View Related

SQL 2012 :: Tuning SP (Left Outer Join)

Mar 21, 2014

I am working on tuning of sp. They wrote several left outer join. Is there any option to avoid them.

View 3 Replies View Related

SQL 2012 :: Value Of Buffer Cache Hit Ratio

Jul 16, 2015

What is better values for Buffer Cache Hot Ratio in SQL Server 2012. Is the values changed from 2008r2 to 2012?

View 2 Replies View Related

SQL 2012 :: Plans Not Staying In Proc Cache

Feb 25, 2015

On one server I'm having an issue with and it having such a small procedure cache.

Server has 60GB of RAM assigned to its min and max server memory settings, optimise for ad hoc workloads is disabled.

Procedure cache at the moment on the server is 2.41MB with only 6 objects in side all related to mssqlsystemresource database, I can see stuff dropping in for user databases, but as soon as the proc has finished the plan is removed from the cache.

Buffer cache is in the 17GB mark, free pages around the 42GB mark so around 60GB used with a bit in stolen pages, but no proc cache.

All other servers in the environment are reporting over 8GB of proc cache in use which is more healthy.

Using Spotlight to monitor all of this.

Whats wrong with this one server and it not keeping the plans in cache.

View 9 Replies View Related

SQL 2012 :: When Does Database Clear Buffer Cache

Sep 28, 2015

We are troubleshooting a performance problem and the test result is slow the 1st time but the subsequent runs are faster.. Logging out of application and log back in ( connecting to a new database session) did not clear the buffer cache as I thought it would.. When does the database clear the buffer cache? Is it not per database session?

I can issue CHECKPOINT and then run DBCC DROPCLEANBUFFERS to clear the buffers in the disk. But since we are testing from the application,do we need to run these commands via application code to clear buffer/per database session OR can we run these commands from a management studio session?

View 8 Replies View Related

SQL 2012 :: Use Of Running DBCC Free Session Cache?

Feb 12, 2015

What is the use of running DBCC FREESESSIONCACHE.

How frequently can we do this on all the databases.

What happens if we schedule to run it every 1min.

Are there any advantages/disadvantages of running this on all databases.

View 5 Replies View Related

SQL 2012 :: Buffer Cache Size Much Lower Than Max Memory Config And Low PLE?

May 22, 2014

I have a virtual server (VMware ESX) with 64GB RAM running a single instance of SQL 2012 SP1. The max memory config is set to 59392 (58GB).

The Page Life Expectancy for this server has been averaging well under 10 mins for the last few days, according to our monitoring.

I have been checking the amount of data in the buffer cache periodically during the day with the below query, which seems to show that there is never more than about 10GB of data at any one time, frequently dropping below 5GB:

SELECT COUNT(*) AS BufferPages,
CONVERT(decimal(10, 2), COUNT(*) / 128.0) AS BufferMB
FROM sys.dm_os_buffer_descriptorsWhy would the amount of cached data be so low (and cause so much churn)?

I am aware that other things will require some of that memory (plan cache etc.) but with Max Mem of 58GB, I would expect there to be a much higher amount of actual cached data at any one time. I did the same checks on another VM with the same amount of RAM/Max Mem setting, and there was 50GB of data in the cache, with PLE measured in hours.

View 9 Replies View Related

SQL 2012 :: Find Buffer Cache Usage By DB Objects Within Particular Database

Jun 22, 2015

I am using SQL 2012 and I am trying to find buffer cache usage by DB objects within a particular DB.

I am running the following query

select
name as DB,
objname as db_object_name,
COUNT(name) as cache_page_count,
COUNT('x')*8.0/1024 as size_mb

[Code] ....

Following are the results:-

DB db_object_name cache_page_countsize_mb
TEST_DBNULL 428 3.34375
TEST_DBsysobjvalues 369 2.882812
TEST_DBsyscolpars 44 0.34375
TEST_DBsysssislog 38 0.296875
....
.....

Question- Why am I getting 428 pages for which there is no corresponding DB object? Why are so many pages present in sys.dm_os_buffer_descriptors but are missing from sys.allocation_units.

View 0 Replies View Related

Integration Services :: Space While Using Cache Transformation In SSIS 2012

Jun 4, 2015

We are using the cache transformation in our project , while doing the cache transformation our disk space goes to 0 MB free and SSIS package execution not completes even after 3 hr..Initially we have around 34 GB free space on C: drive .Our server configuration is 64 RAM. We are caching the data from table which contains around 21 million records.We changed the path in properties (“BLOPTempStoragePath”,”BufferTempStoragePath”) of Data Flow task of SSIS in which we are using Cache Transformation.

View 6 Replies View Related

SQL 2012 :: DB Engine Page Life Expectancy And Buffer Cache Hit Ratio Is Too Low

Sep 12, 2014

Our server administrator forwarded some messages from SCOM that indicate:

SQL DB Engine 2012 Page Life Expectancy and Buffer Cache Hit Ratio is too low

When I logged into the offending server, I could not find anything in the SQL Log File that indicates this.

I was wondering how did SCOM identify this issue - where in SQL Server would this have been reported to SCOM?

View 3 Replies View Related

SQL 2012 :: Select Rows With Blank Spaces

Feb 12, 2014

I got two columns DEATHDATE and STATUS

I have to update STATUS Column as INVALID when data in DEATHDATE column as follows

Example of INAVLID DEATH DATE : 1221, 12xt88,12#10, 1, ABC, #@ , etc

Do nothing when the DEATHDATE is VALID like

Examples of Valid/accepatable DEATHDATE: 09122012, 091212 ,******,********, 000000,00000000

How can i achieve this.

View 1 Replies View Related

SQL 2012 :: Blank (Empty String) In Primary Key

Apr 29, 2014

Can we have blank value in Primary key field? Two fields are chosen as Primary Key for this table but the issue is at any given time one value will be blank when other is populated. Does sql server still order the records based on these keys? (Clustered index). Or should I just go about adding ID (identity)?

View 1 Replies View Related

Unable To Connect To SQL Database 'MySite-Cache' For Cache Dependency Polling.

Dec 27, 2007

 Im getting this error when trying to set up a cache dependency...are there any special permissions etc?From CS:SqlCacheDependency dep = new SqlCacheDependency("MySite-Cache", "Products");Cache.Insert("Products", de.GetAllProductsList(), dep); From connectionStrings.config:<add name="SiteDB"         connectionString="Data Source=localhost,[port]SQLEXPRESS;Integrated Security=true;User Instance=true; AttachDBFileName=|DataDirectory|ASPNETDB.MDF" providerName="System.Data.SqlClient" />Also tried this using my machinename<add name="SiteDB"         connectionString="Data
Source=<machinename>,[port]SQLEXPRESS;Integrated Security=true;User
Instance=true; AttachDBFileName=|DataDirectory|ASPNETDB.MDF"
providerName="System.Data.SqlClient" /> From web.config:       <caching>          <sqlCacheDependency enabled="true" pollTime="10000">              <databases>                  <add name="MySite-Cache" connectionStringName="SiteDB" pollTime="2000"/>              </databases>          </sqlCacheDependency>                </caching> EDIT: So making progress I can't seem to get the table registered for cache dependency:The sample i have says"aspnet_regsql.exe -E -S .SqlExpress -d aspnetdb -t Customers -et"and the command line response is "Enabling the table for SQL cache dependency..An error has happened.  Details of the exception:The table 'Customers' cannot be found in the database."Where does this "Customers" table come from? There is obviously not an application specific "Customers" table in aspnetdb I'm confused probably more by the example than anything.... 

View 3 Replies View Related

Query Tuning

May 28, 2008

Hi,

Mine Below Query takes considerable time at the time of execution.
Can any one help me, what is the other way to write this query?

Declare @p_Mkt_View_Id int
Set @p_Mkt_View_Id = 17


Select Distinct Customer_id From Active_Product_Cust_Dtl
Where Product_Group_Code in
(Select Distinct Product_Group_Code From Products
Where Product_code in (
select Distinct ProductId from pit
where pitid in (select pitid from marketviewdef
where mktviewid = @p_Mkt_View_Id)))

Thanks
Prashant

View 4 Replies View Related

Tuning A Query

Oct 25, 2007

Hi have this query which is taking too much time to execute..........I have tried the following options but not useful till now
1. NOLOCK
2. SET NO ROW COUNT
3. CHANGED DISK LOCATION OF TEMPDB
4. CHECKED %Processor Time
5. Checked pages.sec

Below is the query, any suggestions will be really helpful


SE IFRepository
--Query
--Returns count of txns whose status is not (10001 or 10002)
declare @fileruntimeuid int
declare @Pendingackcount int
set @Pendingackcount =0
set @fileruntimeuid =0
declare @clientname varchar(256)
set @clientname = NULL
declare @txncnt int
set @txncnt = 0
declare @FileNameClient varchar(256)
set @FileNameClient = NULL


declare @StageStatus int
set @StageStatus = 0
declare @StageDesc varchar(35)

declare PendingAcks cursor for
select distinct fileruntimeuid from tiffileruntime WITH (NOLOCK)
where filecreationdt >= convert(smalldatetime,'9-11-07')
and filecreationdt <= convert(smalldatetime,'9-12-07')
and statusid <> 2
--and filetypeuid in (1,8,16,17,18)
--and clientuid =1205
order by fileruntimeuid
--244873, 244883, 244885, 244892, 244893, 244925, 244926, 244966, 244967, 244873, 244883

Print 'File Life Cycle Viewer via Database'
Print '==========================================================================================='
Print 'Status FileRuntimeUID Client Name File Status File name'
Print '==========================================================================================='
Open PendingAcks
FETCH NEXT FROM PendingAcks
into @fileruntimeuid
WHILE @@FETCH_STATUS = 0
BEGIN
select top 1 @StageDesc = b.IFComponentDesc from TIFComponent b, TIFFIleProcessingStatus a
WITH (NOLOCK)
where a.IFComponentUID = b.IFComponentuid
and a.fileruntimeuid = @fileruntimeuid
order by a.FPROCStageStartDt desc-- a.IFComponentUID desc

select @clientname = ClientShortName from tifclientattrib
where clientuid = (select clientuid from tiffileruntime where fileruntimeuid = @fileruntimeuid)

select @StageStatus = statusid, @FileNameClient= FileNameClient from tiffileruntime where fileruntimeuid = @fileruntimeuid
select @txncnt = FProcTxnProcessedInTotal from tiffileprocessingstatus where fileruntimeuid = @fileruntimeuid and IFComponentUID = 5
--if @StageDesc = "" Begin @StageDesc = "------------" End
print RTRIM(convert(varchar(10),@StageStatus)) + ' ' + RTRIM(convert(varchar(10),@fileruntimeuid)) + ' ' + RTRIM(@clientname) + ' ' + @StageDesc + ' ' + RTRIM(@FileNameClient)
set @StageDesc = NULL
FETCH NEXT FROM PendingAcks
into @fileruntimeuid
END

Print '==========================================================================================='
close PendingAcks
deallocate PendingAcks

View 5 Replies View Related

Query Tuning

May 22, 2006

I want to take the execution plan of some transact sql queries, I took the execution plan as text based one, that having

index scan, index seek

Remote scan, remote Update

sort order by cluases

 

in the above clauses what is the high performance, and how will i change to the high performance clauses by changin the query to improve the execution speed of the query

 

Please guide me

 

 

 

the execution plan is

 

 

 



SELECT [Inventory_Profile].[InventoryID]        ,[Inventory_Profile].[Alias]        ,[Inventory_Profile].[InventoryStatusID]        ,[Inventory_Profile].[InventorySubTypeID]        ,[Inventory_Profile].[InventoryTypeID]        ,[Inventory_Profile].[AcquisitionDate]        ,[Inventory_Profile].[UnitNumber]        ,[Inventory_Profile].[YearOfManufacture]        ,[Inventory_Profile].[Manufacturer]        ,[Inventory_Profile].[Make]        ,[Inventory_Profile].[Model]        ,[Inventory_Profile].[SerialNumber]        ,[Inventory_Profile].[UsageConditionID]        ,[Inventory_Profile].[Description1]        ,[Inventory_Profile].[Description2]        ,[Inventory_Profile].[LocationEffectiveFromDate]        ,[Inventory_Profile].[IsFlaggedForSale]        ,[Inventory_Profile].[RentalPurchaseOrderNumber]        ,[Inventory_Profile].[AquisitionPurchaseOrderNumber]        ,[Inventory_Profile].[SortOrder]        ,[Inventory_Profile].[IsSaleLeaseBack]        ,[Inventory_Profile].[InterimRentReceivableUpfrontTaxModeID]        ,[Inventory_Profile].[LeaseRentalReceivableUpfrontTaxModeID]        ,[Inventory_Profile].[OverTermReceivableUpfrontTaxModeID]          ,[TaxDepreciation_Inventory].[IsTaxDepreciationRequired]        ,[TaxDepreciation_Inventory].[IsComputationPending]        ,[TaxDepreciation_Inventory].[TaxDepreciationTemplateID]        ,[TaxDepreciation_Inventory].[InventoryCostBasisAmount]        ,[TaxDepreciation_Inventory].[DepreciationBeginDate]        ,[TaxDepreciation_Inventory].[DepreciationEndDate]     ,[TaxDepreciation_Inventory].[IsTaxDepreciationTerminated]        ,[TaxDepreciation_Inventory].[IsStraightLineMethodUsed]        ,[TaxDepreciation_Inventory].[IsLeaseTermUsedForStraightLineMethod]           ,[Inventory_PTMS].[Division]        ,[Inventory_PTMS].[Branch]        ,[Inventory_PTMS].[SalesTaxPercent]        ,[Inventory_PTMS].[SalesTaxAmount]        ,[Inventory_PTMS].[IsSalesTaxIncluded]        ,[Inventory_PTMS].[GLExpenseAccount]        ,[Inventory_PTMS].[GLAssetAccount]        ,[Inventory_PTMS].[SoftwareExclusionAmount]        ,[Inventory_PTMS].[AssetCategoryCodeID]        ,[Inventory_PTMS].[OwnershipCodeID]        ,[Inventory_PTMS].[ManufacturingCodeID]        ,[Inventory_PTMS].[ReimburseCodeID]        ,[Inventory_PTMS].[BillingStatusID]        ,[Inventory_PTMS].[PropertyTaxExemptionCodeID]        ,[Inventory_PTMS].[UserDefinedField1]        ,[Inventory_PTMS].[UserDefinedField2]        ,[Inventory_PTMS].[Notes]      FROM [Inventory_Profile]    INNER JOIN [TaxDepreciation_Inventory]  ON  [Inventory_Profile].[InventoryID]=[TaxDepreciation_Inventory].[InventoryID]    INNER JOIN [Inventory_PTMS]    ON    [Inventory_Profile].[InventoryID]=[Inventory_PTMS].[InventoryID]    INNER JOIN [Inventory_Status_CnfgLocale]     ON  [Inventory_Profile].[InventoryStatusID] in (SELECT InventoryStatusID FROM  Inventory_Status_CnfgLocale               WHERE InventoryStatusName <> 'Donated'               and   InventoryStatusName <> 'Scrap'                and   InventoryStatusName <>'Write Off'               and   InventoryStatusName <> 'Sold')

 

 

 

 

 

  |--Nested Loops(Inner Join)
       |--Nested Loops(Inner Join, OUTER REFERENCES:([LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[InventoryTaxDepreciationDetailID]))
       |    |--Nested Loops(Inner Join, OUTER REFERENCES:([LW_Winthrop].[dbo].[Inventory_PTMS].[InventoryID]))
       |    |    |--Nested Loops(Left Semi Join, OUTER REFERENCES:([LW_Winthrop].[dbo].[Inventory_Profile].[InventoryStatusID]))
       |    |    |    |--Nested Loops(Inner Join, OUTER REFERENCES:([LW_Winthrop].[dbo].[Inventory_PTMS].[InventoryID]))
       |    |    |    |    |--Clustered Index Scan(OBJECT:([LW_Winthrop].[dbo].[Inventory_PTMS].[PK_IInvPTMS]))
       |    |    |    |    |--Clustered Index Seek(OBJECT:([LW_Winthrop].[dbo].[Inventory_Profile].[PK_IInventory_InvID]), SEEK:([LW_Winthrop].[dbo].[Inventory_Profile].[InventoryID]=[LW_Winthrop].[dbo].[Inventory_PTMS].[InventoryID]) ORDERED FORWARD)
       |    |    |    |--Clustered Index Seek(OBJECT:([LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[PK_cdInvStatus_Locale]), SEEK:([LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[InventoryStatusID]=[LW_Winthrop].[dbo].[Inventory_Profile].[InventoryStatusID]),  WHERE:([LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[InventoryStatusName]<>N'Donated' AND [LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[InventoryStatusName]<>N'Scrap' AND [LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[InventoryStatusName]<>N'Sold' AND [LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[InventoryStatusName]<>N'Write Off') ORDERED FORWARD)
       |    |    |--Index Seek(OBJECT:([LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[UK_ITaxDepInfo]), SEEK:([LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[InventoryID]=[LW_Winthrop].[dbo].[Inventory_PTMS].[InventoryID]) ORDERED FORWARD)
       |    |--Clustered Index Seek(OBJECT:([LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[PK_ITaxDepInfo]), SEEK:([LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[InventoryTaxDepreciationDetailID]=[LW_Winthrop].[dbo].[TaxDepreciation_Inventory].[InventoryTaxDepreciationDetailID]) LOOKUP ORDERED FORWARD)
       |--Clustered Index Scan(OBJECT:([LW_Winthrop].[dbo].[Inventory_Status_CnfgLocale].[PK_cdInvStatus_Locale]))

 

View 6 Replies View Related

Tuning A Distributed Query

Apr 10, 2007

Hello

I have 2 servers: myLocalServer (SQL2005) and myRemoteServer (SQL2000), both in the same LAN. I wish to syncronize a remote table with a local table (both share the same structure) by means of a stored procedure. The amount of rows to carry from the local to the remote table is about 20,000. The query takes more than a minute, and I would like to take down that time. Can you please help me?

myRemoteServer is declared in myLocalServer by means of a Linked Server object, and I declared a synonym called Syn_RemoteTable which represent the remote table.

First I tried a cursor, but it did not worked:

declare curLocalTable cursor local forward_only static read_only for
select ID, Value from myLocalTable where UpdateTimeStamp>@LastUpdate

open curLocalTable
fetch curLocalTable into @ID, @Value

while @@Fetch_Status=0
begin
if exists(select ID from Syn_RemoteTable where ID=@ID)
begin
update Syn_RemoteTable set Value=@Value where ID=@ID
end
else
begin
insert into Syn_RemoteTable (ID, Value) values (@ID, @Value)
end
fetch curVentasMensuales into @ID, @Value
end

close curLocalTable
deallocate curLocalTable


Other way that I tried -performing equally poorly- was:

update Syn_RemoteTable
set Value=T.Value
from Syn_RemoteTable
inner join
(
select ID, Value from myLocalTable where UpdateTimeStamp>@LastUpdate
) as T
on T.ID=Syn_RemoteTable.ID

insert into Syn_RemoteTable
(
ID,
Value
)
select
ID,
Value
from myLocalTable
where
UpdateTimeStamp>@LastUpdate and
ID not in (select ID from Syn_RemoteTable)

View 2 Replies View Related

Fine Tuning This Sql-query. Help!

Jul 20, 2005

Hi, I have problem running this query. It will time out for me...My database are small just about 200 members.I have a site for swaping appartments (rental). my query should lookfor matchin a triangle. Like this member A -> B->CA give his appartment to B. B gives his appartment to C and finallyC gives his appartment to ASoo my query looks for matching parameters like rooms, location, sizeandsoo on..I have one table for existing appartments and one for "whantedappartments"and 1 table called "intresse" where members can store "yes" or "no" ifthey are interessted in a appartment.I also have a table called "omrade" to store locations of interest.Hope you can helpe me with some tip soo i can run this query in a fewseconds instead of 20-30 secThanks MSELECTF.medlemsNr as medlemsNr, F.lfId AS lfId, F.ort AS ort, F.gatuadressAS gatuadress, F.gatuNr AS gatuNr, F.rum AS rum,F.storlek ASstorlek,F.hyra AS hyra, count(F.medlemsNr) As hitsFROMmedlem08 A, medlem08 B, medlem08 C, lagenhetF08 D,lagenhetO08 E, lagenhetF08 F, lagenhetO08 G, lagenhetF08 H,lagenhetO08 IWHERED.rum >= I.rumMin AND D.rum <= I.rumMax ANDD.storlek >= I.storlekMin AND D.storlek <= I.storlekMax ANDI.hyraMax = 0" & " OR D.hyra <= I.hyraMax) ANDI.balkong = '" & "" & "' OR D.balkong = I.balkong) AND(I.badkar = '" & "" & "' OR D.badkar = I.badkar) AND(I.bredband = '" & "" & "' OR D.bredband = I.bredband) AND(I.hiss = '" & "" & "' OR D.hiss = I.hiss) AND(I.spis = '" & "" & "' OR D.spis = I.spis) AND(I.brf = '" & "" & "' OR D.brf = I.brf) ANDD.postNr IN (select postNr from ONSKEMAL08 where loId=I.loId) ANDF.medlemsNr Not IN (select medlemsNr2 from INTRESSE08 wheremedlemsNr1=A.medlemsNr) ANDH.rum >= G.rumMin AND H.rum <= G.rumMax ANDH.storlek >= G.storlekMin AND H.storlek <= G.storlekMax AND(G.hyraMax = 0" & " OR H.hyra <= G.hyraMax) AND(G.balkong = '" & "" & "' OR H.balkong = G.balkong) AND(G.badkar = '" & "" & "' OR H.badkar = G.badkar) AND(G.bredband = '" & "" & "' OR H.bredband = G.bredband) AND(G.spis = '" & "" & "' OR H.spis = G.spis) AND(G.brf = '" & "" & "' OR H.brf = G.brf) ANDH.postNr IN (select postNr from ONSKEMAL08 where loId=G.loId) ANDF.rum >= E.rumMin AND F.rum <= E.rumMax ANDF.storlek >= E.storlekMin AND F.storlek <= E.storlekMax AND(E.hyraMax = 0" & " OR F.hyra <= E.hyraMax) AND(E.balkong = '" & "" & "' OR F.balkong = E.balkong) AND(E.badkar = '" & "" & "' OR F.badkar = E.badkar) AND(E.bredband = '" & "" & "' OR F.bredband = E.bredband) AND(E.hiss = '" & "" & "' OR F.hiss = E.hiss) AND(E.spis = '" & "" & "' OR F.spis = E.spis) AND(E.brf = '" & "" & "' OR F.brf = E.brf) ANDF.postNr IN (select postNr from ONSKEMAL08 where loId=E.loId) ANDA.medlemsNr=D.medlemsNr AND A.medlemsNr=E.medlemsNr ANDB.medlemsNr<>A.medlemsNr AND C.medlemsNr<>A.medlemsNr ANDB.medlemsNr<>C.medlemsNr ANDB.sparr<>1 AND C.sparr<>1 ANDA.typ=11 AND A.medlemsNr=" & session("medlemsNr") & " ANDB.medlemsNr=F.medlemsNr AND B.medlemsNr=G.medlemsNr ANDB.typ=11 AND A.triangel=1 AND B.triangel=1 AND C.triangel=1 AND " &_C.medlemsNr=H.medlemsNr AND C.medlemsNr=I.medlemsNr ANDC.typ=11 group by F.lfId, F.medlemsNr,F.ort,F.gatuadress,F.gatuNr,F.rum,F.storlek,F.hyra

View 9 Replies View Related

SQL2K - Clean Buffer Cache And Procedure Cache.

May 31, 2007

Is there a way to drop clean buffers at the database level instead of the server/instance level like the undocumented DBCC FLUSHPROCINDB (@dbid)??
Is there a workaround for dbo? to be able to flush procedure and data cache without being elevated to sysadmin? server role?

PS: I am aware of the sp_recompile option that can be used to invalidate cached execution plans.
Thx.

View 1 Replies View Related

SQL Server 2008 :: Is Only One Plan Is Kept For One Query In Plan Cache

Mar 14, 2015

Is only one plan is kept for one query in plan cache?

i heard generally hash is created for a query and plan is search with this hash.

View 2 Replies View Related

Query Cache?

Jul 20, 2005

Does SQL Server have a query cache similar to mysql, whereas the queryresult is cached, if the table has not been changed?If so, please refer me to more info.Thanks.--http://www.dbForumz.com/ This article was posted by author's requestArticles individually checked for conformance to usenet standardsTopic URL: http://www.dbForumz.com/General-Dis...pict170423.htmlVisit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=571428

View 1 Replies View Related

MSSQL2000-Self-Join Query Tuning Help

Apr 5, 2007

SELECT * FROM TA a WHERE a.rx=264886 and
AN= (select max(AN) FROM TA where rx=a.rx)

I have a table TA with 8+ million rows and there is clustered PK on (rx, AN) columns. The count on rx=264886 is 6000+ rows. This query takes about 1 to 2 minutes to fetch data. Can anyone suggest how to improve performance and fetch data faster?

Thanks, Vinnie

View 2 Replies View Related

DB Engine :: Query Tuning - IN Operator

Aug 26, 2015

I have a the following query which takes long time

DECLARE @ACCOUNTS TABLE(ACCOUNT_ID INT)
INSERT INTO @ACCOUNTS
SELECT ACCOUNT_ID FROM ACCOUNT
WHERE A_DESCR in ('AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG')

I used the following key words: sql server query tuning in operator 

View 2 Replies View Related

Flush Query Cache

Nov 2, 2005

Is there a clean way to flush the query cache so I can simulate the first execution of an SQL statement any time I want to?

View 3 Replies View Related

See Query Text From Cache

Mar 22, 2006

Hi,

During a trace in profiler, I see some lines that indicate :
exec sp_execute 12
Or
exec sp_execute 24

I suppose these are query in cache and are recall by query processor ? If yes, how can I see this query in clear text ?

Thanks for help

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved