473,511 Members | 14,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Slow return in Oracle stored procedure

132 New Member
Hi there.

I have written a C# web service that calls an Oracle stored procedure. The SP is a simple select-max query and the table it is getting the value from has about 2.8 million rows in it. The field being MAX'd is an index field in the table. I have further ensured that the table has had an analysis and rebuild run on it to ensure good integrity but still I am finding the stored procedure takes around 3 minutes to return the MAX value.

Here are the code examples below:

In the C# the stored procedure is called as follows:

Expand|Select|Wrap|Line Numbers
  1. OracleCommand uprnComm;
  2. uprnComm = new OracleCommand("NLPGnextUPRN", conn);
  3. uprnComm.CommandType = CommandType.StoredProcedure;
  4. OracleParameter outParam = uprnComm.Parameters.Add("p_nextUPRN", OracleType.Char, 12); //12 refers to length of uprn data type
  5. outParam.Direction = ParameterDirection.Output;
  6. uprnComm.ExecuteNonQuery();
  7. string newUPRN = outParam.Value.ToString();
  8.  
And the stored procedure looks like the following:

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE SADAS_MANAGER.NLPGnextUPRN (p_nextUPRN   out varchar2) IS 
  2. BEGIN
  3. select max(uprn) + 1 into p_nextUPRN from nlpg_uk where uprn < 10000000;
  4. END;
  5.  
Also I am finding that if I run the following command directly in the Oracle client, it likewise takes a long time to run:

Expand|Select|Wrap|Line Numbers
  1. select max(uprn) + 1 into p_nextUPRN from nlpg_uk where uprn < 10000000
  2.  
Any ideas please? As this is becoming so confusing so I am assuming there is some form of additional optimising that needs to be carried out on the target table.

Thank you.

M :o)
Feb 11 '09 #1
7 8183
debasisdas
8,127 Recognized Expert Expert
why not use a function instead ?

since data is more ,that execution time is normal.
Feb 11 '09 #2
E11esar
132 New Member
What I am finding though is that if I run the same stored procedure elsewhere then it is a lot more efficient, so I suppose I am wondering if there is anything "obvious" which I can check with the table structure or such, please?

Thank you.

M :o)
Feb 11 '09 #3
debasisdas
8,127 Recognized Expert Expert
are you executing that directly on the server ?
Feb 11 '09 #4
E11esar
132 New Member
@debasisdas

At the moment it is all on the same machine (laptop) but the final solution will have the web service on the same server as the database.

Thank you.

M :o)
Feb 11 '09 #5
amitpatel66
2,367 Recognized Expert Top Contributor
Firstly, why are you declaring a varialbe type as character in your c# code. Make it integer because the return value is going to be always integer. Change it accordingly in Oracle procedure code as well.

Second, Why are you need to create a stored procedure for simple query. Just execute the query directly in your C# instead of putting it in a seperate procedure. If you use a procedure, then your when the procedure executes a PLSQL ENGINE is called,and in turn it need to call a SQL ENGINE to execute your SELECT statement. So if you execute your SELECT directly in your C# then a call from C# to PL/SQL then from PL/SQL to SQL and back to PL/SQL can be eliminated.
Feb 13 '09 #6
E11esar
132 New Member
Thank you. I have done as suggested and the results are excellent.
Feb 13 '09 #7
madankarmukta
308 Contributor
Hi,

Follow the modifications suggested by AmitPatel..I completely agree him.

One more thing you can try is that.. you partition the table you are querying for the specific range of "uprn" values..

Thanks!
Feb 13 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

13
15114
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
16
21256
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around...
1
12191
by: robin via SQLMonster.com | last post by:
I've tried several different way to execute a oracle stored procedure from a DTS package but to no avail. I have a Linked Server setup which does bring back Oracle tables from the server when I...
0
3011
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
0
1905
by: Chan | last post by:
Hi, I am trying to send set of rows from my c# web service to Oracle stored procedure. I think I can get this done using OpenXML in SQL Server. How to implement this in Oracle Stored...
0
2189
by: Tom | last post by:
Looking for some help with stored procedure call issues. Conceptually, I need to pass a data structure as the sole parameter to the Oracle stored procedure. Sounds simple enough....but how? ...
8
11240
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
14
4570
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
23
3370
by: Gloops | last post by:
Hello everybody, Is anyone able to give me some indications about how to develop an Access interface for an Oracle database ? I dispose of Access 2003 (11.6566.8107) SP2, Oracle 9i 9.2.0.1.0...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.