Re: Performance problems with StoredProcedure in Web application

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Frank,

I appreciate the background info.

<snip>

BUT - THE PERFORMANCE:
Where the Text query took approx. 10s, the StoredProcedure took up to 2
minutes to return as the same data!
Does anybody have an idea what might be the reason for that behaviour?

It's probably the fault of the cursor. Any particular reason why you need the cursor? It's not being used by the textual query.

Really appreciate your help - Frank

PS: Finaly two snapshots of the code, first the fast hardcoded version,
second the stored procedure based one:

[OLD]
dwhConnection.ConnectionString=(String)getSessionObject("dwhConnectionString");
generalDataAdapter.SelectCommand.CommandText= "SELECT * FROM MYTABLE";
DataTable dataGridInputTable=new DataTable("general");
generalDataAdapter.Fill(dataGridInputTable);
generalAdapter.Fill(dataGridInputTable);

Stored procedures will commonly out-perform textual queries when selecting data, so I'd imagine that in stress situations the above
might perform worse then a stored procedure that does the same exact thing, but I doubt the opposite will ever be true.

[NEW]
OracleConnection oraConnection=new
OracleConnection((String)getSessionObject("oraConnectionString"));
OracleCommand generalQuery=new
OracleCommand("expt.expt_reports_pkg.getAllExperiments",
oraConnection);
generalQuery.CommandType=CommandType.StoredProcedure;
generalQuery.Parameters.Clear();
generalQuery.Parameters.Add(new OracleParameter("M_CURSOR",
OracleType.Cursor));
generalQuery.Parameters["M_CURSOR"].Direction=ParameterDirection.Output;
OracleDataAdapter currentAdapter=new OracleDataAdapter(generalQuery);
DataTable dataGridInputTable=new DataTable("general");
currentAdapter.Fill(dataGridInputTable);

Stored procedures are much safer to use because they're not susceptible to SQL injection attacks, where the user submits data in the
query string, for example, such as ""frank' OR 1=1) timedelay...". The exception is, of course, when executing dynamic SQL in your
stored procedures. I only mention this because of the background you supplied and how it sounded much more complex then your
example "SELECT * FROM MYTABLE", and the code above that executes the stored procedure. i.e., In your code examples you aren't
dealing with parameters but you seemed to imply that you use them.

I suggest keeping the procedure and removing the cursor to see if that helps.

--
Dave Sexton


.



Relevant Pages

  • How do I do Paging through a large dataset via Stored Procedures
    ... Paging by dynamically altering the SQL Query ... Create stored procedures ... SELECT * FROM STUDENTS ...
    (microsoft.public.dotnet.framework.adonet)
  • Extreme performance issues (SQL Server 2000/ADO.NET/C#)
    ... This process runs very quickly if run through Query ... same exact stored procedures and views, run in the same exact order, through ... system that runs SQL Server (a 4-cpu Xeons system with 2gigs of physical ... When I execute these steps manually through query analyser,, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Help with Stored Procedure
    ... I did mean stuff like system stored procedures (even ... build the query, compile it, and optimize it, then, then this is less ... very not easy using dynamic sql. ...
    (microsoft.public.sqlserver.programming)
  • Re: Store procedure vs Direct statement ???
    ... Try opening up query analyzer and checking out the query plan or ... advantages of using stored procedures over not using stored procedures is the ... the better the overall performance of your SQL ... dynamic sql versus the execution plan for a stored procedure. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Access migration to SQL Server
    ... >> about having to convert all your queries to views and stored procedures. ... >> using a named query parameter to look up a value from a form control and ... >> allowing editing of values from multiple tables in a query with a join. ... >> field, checking for NULL in Boolean fields, etc. ...
    (microsoft.public.sqlserver.server)