Article View: borland.public.cppbuilder.database.dbexpress
Article #20Poor performance with stored procedures
From: vbnm
Date: Wed, 01 Mar 2006 09:26
Date: Wed, 01 Mar 2006 09:26
54 lines
3027 bytes
3027 bytes
Hi there,
i've a problem concerning stored procedures with cppbuilder 6.0,
dbexpress and mssql server 2000.
for testing i created the following stored procedure on sql server:
CREATE PROCEDURE sp_CountPatients
@result int OUTPUT,
@p int
AS
SELECT @result = COUNT(*) FROM Patient
WHERE LastName LIKE '%' + CAST(@p AS varchar) + '%'
RETURN
GO
the code to test this procedure:
TSQLStoredProc *sp = new TSQLStoredProc(this);
sp->SQLConnection = CommonDataModule->SQLConnection;
sp->StoredProcName = "sp_CountPatients";
sp->Params->ParamByName("p")->AsInteger = 1 ;
sp->ExecProc();
int t1 = sp->ParamByName("result")->AsInteger;
return t1;
as i realized poor performance by using this stored procedure i did a
trace with SQL Profiler which gave me the following result:
RowNumber EventClass TextData
----------- ----------- -------------------------
1 12 DECLARE @SCH CHAR(200) ...
2 12 DECLARE @SCH CHAR(200) ...
3 10 declare @P1 int set @P1=1 ...
The statment in Row 1 and 2 is exactly the same, is very lage (66
Lines) and is executed every time before the stored procedure is
executed. The result of this statement gives me the parameters of the
stored procedure with informations about data type and so on.
I guessed this is because default the ParamCheck Property of
TSQLStoredProcedure is set to true. I did some testing, set
sp->ParamCheck = false, so i could avoid the double execution of this
statement. But the problem is still present, every time i execute this
stored procedure, this statement is executed.
I did some testing with BDE, there is no Statement for the Parameters
executed, but i try to find a solution for dbexpress ... :)
has anyone an idea where this Statement come from and how to disable
this ?
Thanks in advance
Michael
Technical Details
Message-ID:
<1141205171.131017.37580@i39g2000cwa.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!i39g2000cwa.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: fb4e2,cb461bbb65b714fb,start X-Google-Attributes: gidfb4e2,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!i39g2000cwa.googlegroups.com!not-for-mail From: "vbnm" <michael.giretzlehner@gmail.com> Newsgroups: borland.public.cppbuilder.database.dbexpress Subject: Poor performance with stored procedures Date: 1 Mar 2006 01:26:11 -0800 Organization: http://groups.google.com Lines: 55 Message-ID: <1141205171.131017.37580@i39g2000cwa.googlegroups.com> NNTP-Posting-Host: 193.170.124.158 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1141205176 22842 127.0.0.1 (1 Mar 2006 09:26:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 1 Mar 2006 09:26:16 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i39g2000cwa.googlegroups.com; posting-host=193.170.124.158; posting-account=-V95aw0AAAAYQbSTkUDLKNBseLptpErz