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)
The full store procedure code is as follow :
set
ANSI_NULLSONset
QUOTED_IDENTIFIERONgo
-- =============================================
-- 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 languageSET @CurrentSelectedLang =(SELECT [Id] FROM [NomosConfig].[dbo].LanguageWHERE [Selected]=1)-- Update language table according to new languageIF(@CurrentSelectedLang <>@Lang)BEGIN-- Update statements for procedure hereUPDATE [NomosConfig].[dbo].LanguageSET [Selected]=0WHERE [Id]= @CurrentSelectedLangUPDATE [NomosConfig].[dbo].LanguageSET [Selected]=1WHERE [Id]= @Lang ENDCOMMITTRANSACTIONEND
and the table structure is defined as follow :
USE
[NomosConfig]GO
/****** Object: Table [dbo].[Language] Script Date: 02/18/2008 13:32:03 ******/
SET
ANSI_NULLSONGO
SET
QUOTED_IDENTIFIERONGO
SET
ANSI_PADDINGONGO
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