Once again, I find something that can hamper the performance of my SQL query, please have a look, it may be quite informative.
Some time the SQL statement take so long time (in distributed query in remote server environment) to execute and it takes a long CPU time and sometimes it's so slow that u can go outside take some snakes and till it is running.
In this type of condition we always think about missing index or table scan is the main culprit. By using profiler for any others executions tolls you find that alls are ok the main one is API server cursor, so I try to illustrate this in my blog.
SQL Server OLEDB provider use 2 types of methods for fetching data form distributed server.
1. A default result set will fetch the results of the distributed query from a remote server in a single batch.
2. The other method utilizes a cursor, referred to as an API Server Cursor, to fetch the results of the distributed query from the remote server.
When using an API server cursor in OLE DB, ODBC, and ADO, use the functions or methods of the API to:
- Open a connection.
- Set attributes or properties defining the characteristics of the cursor the API automatically maps over each result set.
- Execute one or more Transact-SQL statements.
- Use API functions or methods to fetch the rows in the result sets.
In SQL profiler when we find the "Stored procedure-RPC compiled" that means that the procedure that used by API Server cursors.
Example of distributed query
SELECT *
FROM RemoteServer.RemoteDatabase.dbo.RemoteTable0 as t0
INNER JOIN RemoteServer.RemoteDatabase.dbo.RemoteTable1 as t1
ON t0.Account = t1.Account
WHERE t0.Account = 'XYZ'
In SQL server profiler trace
The TextData column for the RPC:Completed events expose the execution of the system stored procedure, sp_cursorfetch.
For each execution of this system stored procedure a round-trip between the two servers is made. The previous statement and the results of the SQL Server Profiler trace should clearly illustrate why using an API Server Cursor has the potential to quickly become a major performance problem. Elaborating on this, the sp_cursorfetch system stored procedure is executed as a series of batches until all of the data has been returned from the remote server. The last parameter passed into the sp_cursorfetch system stored procedure is the number of records that are processed for each execution.
In this case, 100 records are processed for each execution of the sp_cursorfetch system stored procedure – Therefore, my example processes about 6000 records in total, for a series of 60 executions with each execution making a round-trip between the servers.
For better understanding http://msdn.microsoft.com/en-gb/library/aa172588(SQL.80).aspx
Posted By : MR. JOYDEEP DAS
Very useful and interesting information you have been posted. This post is useful for students. We also providing Software Testing Online Course in Hyderabad.
ReplyDeleteelazığ
ReplyDeletebilecik
kilis
sakarya
yozgat
JXY
uşak
ReplyDeletevan
hakkari
elazığ
bingöl
JMFVHN
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
V18
48D5C
ReplyDeleteErzincan Şehir İçi Nakliyat
Silivri Evden Eve Nakliyat
Kars Parça Eşya Taşıma
Kütahya Evden Eve Nakliyat
Çerkezköy Oto Elektrik
Eryaman Parke Ustası
Uşak Evden Eve Nakliyat
Çorum Lojistik
Bursa Şehirler Arası Nakliyat
85B77
ReplyDeleteVan Parça Eşya Taşıma
Sinop Evden Eve Nakliyat
Eskişehir Şehirler Arası Nakliyat
Ünye Parke Ustası
Bitlis Şehir İçi Nakliyat
Ardahan Şehirler Arası Nakliyat
Sakarya Şehir İçi Nakliyat
Trabzon Parça Eşya Taşıma
Denizli Evden Eve Nakliyat
E3E88
ReplyDeletebinance %20
4E58E
ReplyDeletebinance %20 komisyon indirimi
F0672
ReplyDeletereferanskodunedir.com.tr
B16D7
ReplyDeleteBitcoin Kazanma
Coin Madenciliği Siteleri
Coin Çıkarma
Kripto Para Nasıl Alınır
Yeni Çıkan Coin Nasıl Alınır
Okex Borsası Güvenilir mi
Bitcoin Kazma Siteleri
Bitcoin Hesap Açma
Bitcoin Nasıl Çıkarılır
BA533
ReplyDeleteSoundcloud Reposts Hilesi
Hamster Coin Hangi Borsada
Facebook Beğeni Hilesi
Tumblr Takipçi Satın Al
Bitcoin Kazma
Mexc Borsası Kimin
Bonk Coin Hangi Borsada
Bitcoin Nasıl Alınır
Binance Para Kazanma
995D4
ReplyDeleteBitcoin Nasıl Kazılır
Binance Hangi Ülkenin
Coin Kazanma
Instagram Takipçi Hilesi
Luffy Coin Hangi Borsada
Binance Ne Kadar Komisyon Alıyor
Clubhouse Takipçi Hilesi
Qlc Coin Hangi Borsada
Twitter Retweet Satın Al
18CC9
ReplyDeleteAvcılar
Çemişgezek
Çelebi
Otlukbeli
Ağın
Hadim
Mazgirt
Bayramören
Kızılören
A7CB0
ReplyDeleteFacebook Grup Üyesi Satın Al
Meta Coin Hangi Borsada
Binance Ne Kadar Komisyon Alıyor
Threads Yeniden Paylaş Satın Al
Sohbet
Telcoin Coin Hangi Borsada
Gate io Borsası Güvenilir mi
Twitch İzlenme Satın Al
Facebook Beğeni Satın Al