Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

how optimize based on execution plan info ??

$
0
0

 

dear all,

I have a simple store procedure which make a field selection and based on it update a particular column.

problem I have when executing this procedure and check the execution plan, I have a 100% cost on the statement :

 

SET @CurrentSelectedLang =(SELECT [Id] FROM [NomosConfig].[dbo].Language

WHERE [Selected]=1)

 

Code Snippet

 

The full store procedure code is as follow :

 

set

ANSI_NULLSON

set

QUOTED_IDENTIFIERON

go

-- =============================================

-- Author: CAL

-- Create date: 27/09/2007

-- Description: Switch language

-- Called by : Maillefer.Nomos.Plateform.EventHistorySys

-- =============================================

ALTER

PROCEDURE [dbo].[ChangeLanguage]

-- Add the parameters for the stored procedure here

@Lang

varchar(5)

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SETNOCOUNTON;

DECLARE @CurrentSelectedLang char(5);

BEGINTRANSACTION

-- read current selected language

SET @CurrentSelectedLang =(SELECT [Id] FROM [NomosConfig].[dbo].Language

WHERE [Selected]=1)

-- Update language table according to new language

IF(@CurrentSelectedLang <>@Lang)

BEGIN

-- Update statements for procedure here

UPDATE [NomosConfig].[dbo].Language

SET [Selected]=0

WHERE [Id]= @CurrentSelectedLang

UPDATE [NomosConfig].[dbo].Language

SET [Selected]=1

WHERE [Id]= @Lang

END

COMMITTRANSACTION

END

 

 

 

and the table structure is defined as follow :

Code Snippet

USE

[NomosConfig]

GO

/****** Object: Table [dbo].[Language] Script Date: 02/18/2008 13:32:03 ******/

SET

ANSI_NULLSON

GO

SET

QUOTED_IDENTIFIERON

GO

SET

ANSI_PADDINGON

GO

CREATE

TABLE [dbo].[Language](

[Id] [varchar]

(5)COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL,

[Name] [varchar]

(50)COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL,

[Selected] [bit]

NOTNULLCONSTRAINT [DF_Language_Selected] DEFAULT((0)),

CONSTRAINT [PK_Language] PRIMARYKEYCLUSTERED

(

[Id]

ASC

)

WITH(IGNORE_DUP_KEY =OFF)ON [PRIMARY]

)

ON [PRIMARY]

GO

SET

ANSI_PADDINGOFF

 

 

 

What is the way on this simple table structure and procedure , to reduce this cost ?

 

thnaks for your help

regards

serge

 


Viewing all articles
Browse latest Browse all 15264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>