Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Verification on performance
Message
De
04/10/2010 03:11:03
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Verification on performance
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01483774
Message ID:
01483774
Vues:
125
The following script usually takes a flash to execute:
SET ANSI_WARNINGS OFF
DECLARE @ExecuteSql nvarchar(4000)
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Client' AND COLUMN_NAME = 'test4')
   BEGIN
      BEGIN TRY
         PRINT @ExecuteSql
         SET @ExecuteSql = N'ALTER TABLE [Client] ADD [test4] char(40)'
         EXEC sp_executesql @ExecuteSql
         SET @ExecuteSql = N'UPDATE [Client] SET [test4]='''''
         PRINT @ExecuteSql
         EXEC sp_executesql @ExecuteSql
      END TRY
      BEGIN CATCH
         Print ERROR_MESSAGE()
      END CATCH
   END
   ELSE
   BEGIN
      BEGIN TRY
         SET @ExecuteSql = N'ALTER TABLE [Client] ADD [test4-Temporary] char(40)'
         PRINT @ExecuteSql
         EXEC sp_executesql @ExecuteSql
         SET @ExecuteSql = N'UPDATE [Client] SET [test4-Temporary]=test4'
         PRINT @ExecuteSql
         EXEC sp_executesql @ExecuteSql
         SET @ExecuteSql = N'ALTER TABLE [Client] DROP COLUMN [test4]'
         PRINT @ExecuteSql
         EXEC sp_executesql @ExecuteSql
         PRINT 'Renaming the field'
         EXEC sp_RENAME 'Client.test4-Temporary', 'test4' , 'COLUMN'
      END TRY
      BEGIN CATCH
         Print ERROR_MESSAGE()
      END CATCH
   END
Basically, this adds a field into a table.

I have been trying to find what was causing a latency recently. Basically, this now takes 6 seconds to execute.

I cannot understand what caused the latency on that specific server. If I execute that script directly in SSMS on that server, it is fast. If I execute the same script through .NET, by the use of SMO, with something like loServer.ConnectionContext.ExecuteNonQuery(lcScript), it takes longer. But, when this is done from .NET, the server is not the same box as the Web server. If I execute the same .NET code to execute other scripts, it is fast. It is just that one. Something in there is conflicting with something else and it causes some delay in the execution. Anyone would know what it could be?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform