Problem with speed using ODP and DataReader

We are developing an application that uses an Oracle database and are having problems trying to optiomise some of the query handling.
The application is written in C#, using Visual Studio, .NET 1.1, ODP 11g, and connects to a 10gR2 database with Locator extensions.
Below is a typical example of the problems we are encountering.
The stored procedure "GET_POLYGONS_IN_AREA" retrieves an ID, a StyleID and the geometry data for all polygons in the area specified by the input paramaters.
The Explain Plan for this shows that the query (when returning about 4000 polygons) should take about 0.4 secs.
(we have improved things by using better indexes or indexed clusters, but this is insignificant compared to the problem below)
Using SQL Developer, the query does indeed typically return under half a second.
However, when trying to access the results via .NET using the OracleDataProvider, things are very different.
The code snippet below calls the stored procedure and uses an OracleDataReader to retrieve the results.
The call to the first read() is timed and the result output, along with the value for the timing returned by the Oracle procedure.
The result is that the same region typically returns:
Time in Oracle: <0.5 secs, Time for the dr.read(): 5 secs!
This performance level is clearly not what we need.
We have inserted the suggested technique for obtaining the rowsize of the ref cursor (which returns 80).
However, adjusting the fetchsize makes almost no difference - even a value of 10000000 still gives the time for the rd.read() over 4 secs.
Help!
Why is dr.read() taking soooo long when the Oracle query does not and, more importantly, how can we speed this up or get round it so we can get good performance?
Richard
SQL stored procedure:
PROCEDURE "GET_POLYGONS_IN_AREA" (
minX IN NUMBER,
minY IN NUMBER,
maxX IN NUMBER,
maxY IN NUMBER,
timeTakenInHundredthSecs OUT NUMBER,
"RETDATA" OUT NOCOPY SYS_REFCURSOR
IS
tableCursor SYS_REFCURSOR;
thisGeom sdo_geometry;
timeBefore BINARY_INTEGER;
timeAfter BINARY_INTEGER;
BEGIN
timeBefore := DBMS_UTILITY.GET_TIME;
OPEN tableCursor FOR
SELECT VERSIONINFO.ID, VERSIONINFO.STYLEID, STYLEDPOLYGON.GEOMETRY
FROM STYLEDPOLYGON , REGIONALINFO, VERSIONINFO
WHERE
sdo_relate(GEOMETRY,
SDO_Geometry(2003,NULL,NULL,
SDO_elem_info_array(1,1003,3),
SDO_ordinate_array(minX,minY,maxX,maxY)),'mask=anyinteract'
) = 'TRUE'
AND STYLEDPOLYGON.ID = REGIONALINFO.POLYGON
AND REGIONALINFOID = VERSIONINFO.ID
AND VERSIONINFO.status = 1
retdata := tableCursor;
timeAfter := DBMS_UTILITY.GET_TIME;
timeTakenInHundredthSecs := time_after - time_before;
DBMS_OUTPUT.PUT_LINE (timeTakenInHundredthSecs );
END "GET_POLYGONS_IN_AREA";
Code to call the procedure:
dbCommand.CommandText = "GET_POLYGONS_IN_AREA";
dbCommand.CommandType = System.Data.CommandType.StoredProcedure;
dbCommand.Parameters.Clear();
dbCommand.Parameters.Add(new OracleParameter("@minX", Oracle.DataAccess.Client.OracleDbType.Decimal));
dbCommand.Parameters.Add(new OracleParameter("@minY", Oracle.DataAccess.Client.OracleDbType.Decimal));
dbCommand.Parameters.Add(new OracleParameter("@maxX", Oracle.DataAccess.Client.OracleDbType.Decimal));
dbCommand.Parameters.Add(new OracleParameter("@maxY", Oracle.DataAccess.Client.OracleDbType.Decimal));
dbCommand.Parameters["@minX"].Value = currentView.MinX;
dbCommand.Parameters["@minY"].Value = currentView.MinY;
dbCommand.Parameters["@maxX"].Value = currentView.MaxX;
dbCommand.Parameters["@maxY"].Value = currentView.MaxY;
dbCommand.Parameters.Add(new OracleParameter("timeTakenInHundredthSecs", Oracle.DataAccess.Client.OracleDbType.Int32)).Direction = System.Data.ParameterDirection.Output;
dbCommand.Parameters.Add(new OracleParameter("RETDATA", Oracle.DataAccess.Client.OracleDbType.RefCursor)).Direction = System.Data.ParameterDirection.Output;
OracleDataReader dr = dbCommand.ExecuteReader();
timeBefore = DateTime.Now;
dr.FetchSize =10000000; // default is 65535
res = dr.Read();
timeAfter = DateTime.Now;
int timeForRead = timeAfter.Subtract(timeBefore).Seconds*1000 + timeAfter.Subtract(timeBefore).Milliseconds;
int timeTaken =10* (int)dbCommand.Parameters["timeTakenInHundredthSecs"].Value;
MessageBox("Time (mS) in Oracle: " + timeTaken.ToString() + ", Time (mS) for dr.read(): " + timeForRead.ToString());
while (res)
// do stuff...
res = dr.Read();
dr.Close();
dr.Dispose();
//-------------------------------------------------------------------------

A few remarks:
1. You fetch 4000 polygons but we don't know how many points these polygons have on average so it is hard to judge if 5 seconds is long or short.
2. You use a variable tableCursor SYS_REFCURSOR in PL/SQL proc and you do
retdata := tableCursor;
I think you can delete tableCursor and you can simply do:
OPEN retdata FOR
SELECT VERSIONINFO.ID, .....
The use of variable tableCursos is unnecessary.
3. It is hard to tell from your results whether the fetching is slow or the query is slow?
Your measurement is skewed.I don't know how you measured the time that sql developer takes to fetch all rows? Normally sql developer doesn't fetch all the rows.
You should create an extra table dummypolygon and do insert into dummypolygon .. select ... where ..sdo_relate... . Now you can measure how long it takes to fetch the 4000 polygons by selecting from this table:
select * from dummypolygon
How long does this take in ODP.NET?
4. Maybe you can speed up the query by using a hint
select /*+ all_rows */ VERSIONINFO.ID ....
5. Maybe you can speed up the query by doing:
OPEN tableCursor FOR
SELECT VERSIONINFO.ID, VERSIONINFO.STYLEID, STYLEDPOLYGON.GEOMETRY
FROM STYLEDPOLYGON , REGIONALINFO, VERSIONINFO
WHERE
sdo_filter(GEOMETRY,
SDO_Geometry(2003,NULL,NULL,
SDO_elem_info_array(1,1003,3),
SDO_ordinate_array(minX,minY,maxX,maxY))) = 'TRUE'
AND STYLEDPOLYGON.ID = REGIONALINFO.POLYGON
AND REGIONALINFOID = VERSIONINFO.ID
AND VERSIONINFO.status = 1;
Be aware, using sdo_filter instead of sdo_relate will give slightly different results but sdo_filter is faster.

Similar Messages

  • Problem with touchpad using firefox and windows 8.1. I don't have a problem with explorer 11.

    new HP computer with windows 8.1. Firefox does not work well with the touch pad when scrolling . very slow and erratic, most noticeable when using facebook. I don't have this problem when using Internet Explorer 11.
    Old computer had windows 7 and my preference was to use firefox over explore. At this time i'm being forced to use explore and firefox is to aggravating to use.

    Currently Firefox is not available for metro devices.
    However, make sure that the touch features are enabled by searching for "touch" in the about:config entries.
    In order to change your Firefox Configuration please do the following steps :
    # In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
    # Click '''I'll be careful, I promise!''' to continue to the about:config page.

  • MPI problem with mpirun, using mpicc and simple hellworld program.

    analog to my stackoverflow post I need help with mpi. I am using openmpi and this is my sourcecode:
    #include <stdio.h>
    #include <mpi.h>
    main (int argc, char* argv[]) {
    int myrank;
    int size;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    printf("Hello World. I'm process %d of %d processes.", myrank, size);
    MPI_Finalize();
    return 0;
    If I now do:
    mpicc test.c -o test
    this works fine, but
    mpirun -np 2 test
    I get the error:
    mpirun noticed that the job aborted, but has no info as to the process
    that caused that situation.
    What could be the reason for this problem???
    What can I do now?
    Do you need further information?
    Last edited by vsilv (2013-11-13 17:27:37)

    Fixed broken link, moving to Programming and Scripting...
    Please edit your post title to better reflect your issue: https://wiki.archlinux.org/index.php/Fo … ow_to_Post

  • Problem in creating client side PDF with image using flex and AlivePD

    I need a favor I am creating client side PDF with image using flex and AlivePDF for a web based application. Images have been generated on that pdf but it is creating problem for large size images as half of the image disappeared from that pdf.I am taking the image inside a canvas . How do i control my images so that they come fit on that pdf file for any image size that i take.
    Thanks in advance
    Atishay

    I am having a similar and more serious problem. It takes a
    long time to execute, but even attaching a small image balloons the
    pdf to 6MB plus. After a few images it gets up to 20MB. These are
    100k jpeg files being attached. The resulting PDF is too large to
    email or process effectively. Does anyone know how to reduce
    size/processing?

  • Hello. I have a problem with OEL 6.5 and ocfs2. When I mount ocfs2 with mount -a command all ocfs2 partitions mount and work, but when I reboot no ocfs2 partitions auto mount. No error messages in log. I use DAS FC and iSCSI FC.

    Hello.
    I have a problem with OEL 6.5 and ocfs2.
    When I mount ocfs2 with mount -a command all ocfs2 partitions mount and work, but when I reboot no ocfs2 partitions auto mount. No error messages in log. I use DAS FC and iSCSI FC.
    fstab:
    UUID=32130a0b-2e15-4067-9e65-62b7b3e53c72 /some/4 ocfs2 _netdev,defaults 0 0
    #UUID=af522894-c51e-45d6-bce8-c0206322d7ab /some/9 ocfs2 _netdev,defaults 0 0
    UUID=1126b3d2-09aa-4be0-8826-0b2a590ab995 /some/3 ocfs2 _netdev,defaults 0 0
    #UUID=9ea9113d-edcf-47ca-9c64-c0d4e18149c1 /some/8 ocfs2 _netdev,defaults 0 0
    UUID=a368f830-0808-4832-b294-d2d1bf909813 /some/5 ocfs2 _netdev,defaults 0 0
    UUID=ee816860-5a95-493c-8559-9d528e557a6d /some/6 ocfs2 _netdev,defaults 0 0
    UUID=3f87634f-7dbf-46ba-a84c-e8606b40acfe /some/7 ocfs2 _netdev,defaults 0 0
    UUID=5def16d7-1f58-4691-9d46-f3fa72b74890 /some/1 ocfs2 _netdev,defaults 0 0
    UUID=0e682b5a-8d75-40d1-8983-fa39dd5a0e54 /some/2 ocfs2 _netdev,defaults 0 0

    What is the output of:
    # chkconfig --list o2cb
    # chkconfig --list ocfs2
    # cat /etc/ocfs2/cluster.conf

  • I am using i 4 phone. recently I had a problem with my lap top and had formatted hard disk of it. Now I want to use sync data in my iphone back to itune n my lap top. how can I perform this task with out loosing data in my i phone.

    I am using i 4 phone. recently I had a problem with my lap top and had formatted hard disk of it. Now I want to sync data in my iphone back to itune on my lap top. how can I perform this task with out loosing data in my i phone.

    Hey floridiansue,
    Do you have an installed email program such as Microsoft Outlook?  If your email is through an online login, such as Gmail, etc, then one will have to create an email association with a program such as Microsoft Outlook on the PC for this Scan to Email system to function.
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
    I am not an HP employee.

  • HT201210 nowadays have many user have problem with update to ios7 and need active with apple id maybe in the future in order escape from these problems must be stop use these products else. Because of simple user don't know about this technology and somet

    nowadays have many user have problem with update to ios7 and need active with apple id maybe in the future in order escape from these problems must be stop use these products else. Because of simple user don't know about this technology and sometime just hear from other user that it 's difficult to use then force they change phone that use to handle to another.

    It is a feature to discourage the theft of iPhones by making them useless if resold. It's not going anywhere. It's simple: just don't buy a phone until you make sure that the activation lock has been disabled.

  • I downloaded a new version of firefox. It said it had problems with my norton toolbar and now it doesn't feature it in the window. I'm not that comp savvy. How do I either get the Norton toolbar up or go back to the old firefox? Thank you.

    I downloaded a new version of firefox. It said it had problems with my norton toolbar and now it doesn't feature it in the window. I'm not that comp savvy. How do I either get the Norton toolbar up or go back to the old firefox? Thank you.

    Please authorize ADE 3 with same credentials that you used with older version of ADE

  • Problem with java swing button and loop

    Problem with java swing button and loop
    I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
    I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
    When I click on start button it must do next:
    Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
    And when I click on stop button it must do next:
    Start button must set enabled and selected and Stop button must set disenabled.
    Field status is set to 0.
    This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
    There is java code, so you can get better picture:
    /** start button */
    public void gStart_ActionEvents() {
    try {
    ivjGStart.setEnabled(false);
    ivjGStop.setEnabled(true);
    ivjGStop.setSelected(true);
    getJTextPane1().setText("Program is running ...");
    Status = 1;
    } catch (Exception e) {}
    /** stop button */
    public void gStop_ActionEvents() {
    try {
    ivjGStart.setEnabled(true);
    ivjGStart.setSelected(true);
    ivjGStop.setEnabled(false);
    getJTextPane1().setText("Program is NOT running ...");
    Status = 0;
    } catch (Exception e) {
    /** procedure IzvajajNeprekinjeno() */
    public void IzvajajNeprekinjeno() {  //RunLoop
    try {
    int zamik = 2000; //delay
    do {
    Thread.sleep(zamik);
    PreberiDat(); //procedure
    } while (Status == 1);
    } catch (Exception e) {
    So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
    Any help will be appreciated.
    Best regards,
    Tomi

    This is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
    Since java is task-based this will happen if you do like this:
    1. Button "Start" is pressed. Thread running: GUI_Thread
    2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
    3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
    4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
    5. Call PreberiDat(). Thread running: GUI_Thread
    6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
    Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
    What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    This tutorial explains how to build a multi threaded gui.
    /Lime

  • I have problem with syncing in itunes and it stared since i installed new version of itunes.it stuck in backup step for houres.what shud i do?

    I have problem with syncing in itunes and it stared since i installed new version of itunes.it stuck in backup step for houres.what shud i do?

    So, in iTunes, when you look at the shuffle's content (in the sidebar) and click on the playlist under the shuffle, over to the right, the songs are in your desired order, correct?  Where do you look, or what do you do, that indicates the playlists are in alphabetical order?  Are you saying that when you play the songs while using the shuffle, they play in alphabetical order?
    If so, when you listen to the songs on the shuffle, are you using the playlist, or are you using the All Songs list? If you are in the default All Songs list, with the shuffle's power switch set to play-in-order (the middle position), the songs play alphabetically, I believe. 
    The 3rd gen shuffle uses VoiceOver.  If you are in the All Songs list, you need to use VoiceOver to switch to the playlist (see manual linked below for details).  When you are in the playlist (with the shuffle's power switch set to play-in-order), then the songs should play in playlist order.
    There are more details in the manual for the 3rd gen shuffle, which is online here
    http://manuals.info.apple.com/en_US/iPod_shuffle_3rdGen_UG.pdf
    See page 22 for the section about setting up and using VoiceOver.  The part about switching playlists starts on page 23 (Using the Playlist Menu).

  • TS1646 hello  I have problem with regist my visa and I cannot buy from store the message came in the end of form is says the phone number must be a 7-digit number and I have writed but not accepted iam from saudi arabia my mobile is 966504850992 pls answe

    hello 
    I have problem with regist my visa and I cannot buy from store
    the message came in the end of form is says
    the phone number must be a 7-digit number
    and I have writed but not accepted
    iam from saudi arabia
    my mobile is 966504850992
    pls answer
    thanks
    dfr aldossary

    Wow, Karan Taneja, you've just embarrassed yourself on a worldwide support forum.  Not only is your post ridiculous and completely inappropriate for a technical support forum, but it also shows your ignorance as to whom you think the audience is.  Apple is not here.  It's users, like you. 
    If you would have spent half the time actually reading the Terms of Use of this forum that YOU agreed to by signing up to post, as you did composing that usesless, inappropriate post, you (and the rest of us on this forum) would have been much better off.

  • I have an older version of Adobe Digital Editions (around 3 years old) and was very happy with it.  Then I had problems with my Kobo Reader and asked a friend who works in IT to assist. She could not fix the Kobo but she messed up my Addobe. She downloade

    I have an older version of Adobe Digital Editions (around 3 years old) and was very happy with it.
    Then I had problems with my Kobo Reader and asked a friend who works in IT to assist. She could not fix the Kobo but she messed up my Addobe. She downloaded version three and I have an account and a password - was not able to transfer my books from my reader to version three (and I don't like the lay-out - I would prefer to stay with the old version as I also loose all my download date info..)
    But all the books I have bought over the last three years are in the old Adobe Digital and I cannot access them any more. When I use it I get the message "that the document is licensed to a different account. I can't even open the books on my computer.
    When I go to my Kobo library, I cannot also not open my books and get the message "this doc is protected by adobe digital rights management and is not currently authorized for use with your adobe. please sign in with your authorized adobe id and try again"
    I believe the problem is that I do not seem to have a digital id for my old adobe or that the Kobo is not in sync with it anymore.
    can you please help me - going on vacation in three days and cannot go without books.

    Please authorize ADE 3 with same credentials that you used with older version of ADE

  • IE11 Problem with Windows 8.1 and IIS 8.5

    I have upgraded my computer from Windows 8 to Windows 8.1, 64bit and IIS 8.5 is installed on the upgraded machine. I am unable to view with IE11 the default page of the default website  hosted on the local machine. The problem occurs with both
    the desktop version of IE11 and the Windows 8 metro style version.
    When Chrome is installed on the machine the page is visible but when using IE11 a "This page can't be displayed" message appears. The IIS Log Files reveal that it is receiving nothing from IE11. Other machines I have that have also been upgraded
    to Windows 8.1 exhibit the same fault.
    The strange thing is that when viewing pages on other networked machines exhibiting the same problem, you can see the pages on the remote machines but in all instances the local page cannot be viewed.
    It appears that there is a problem with IE11. Uninstalling and reinstalling IE11 does not fix the problem.
    Can anyone help me? Assitance with this problem would be most appreciated. 

    Description
    <dir>
    </dir><dir></dir><dir></dir><dir>
    Faulting Application Path: C:\Program Files (x86)\Internet Explorer\iexplore.exe
    </dir>
    Problem signature
    <dir>
    </dir><dir></dir><dir></dir><dir>
    Problem Event Name: APPCRASH
    Application Name: IEXPLORE.EXE
    Application Version: 11.0.9600.16384
    Application Timestamp: 52157231
    Fault Module Name: MSHTML.dll
    Fault Module Version: 11.0.9600.16432
    Fault Module Timestamp: 52620354
    Exception Code: c0000005
    Exception Offset: 002964a7
    OS Version: 6.3.9600.2.0.0.256.48
    Locale ID: 2057
    Additional Information 1: ab90
    Additional Information 2: ab9026eb5cad8b25f882a373e2d752b2
    Additional Information 3: d486
    Additional Information 4: d48664e52db6f0b0676e13c96e422192
    </dir>
    Extra information about the problem
    <dir>
    </dir><dir></dir><dir></dir><dir>
    Bucket ID: 45b7b98d077be82c89ec9142c2213a5f (-374769956)
    </dir>

  • I'm having problems with CS2 (mainly illustrator and photoshop

    I'm having problems with CS2 (mainly illustrator and photoshop ) randomly shutting down while trying to save a file. Reformatted my laptop for fear of a virus and reloaded... I have gotten nowhere.
    Please Help!

    CS3 still had issues with the preferences becoming corrupt, so a possible workaround would be to reset the preferences.
    The file is called AIPrefs and is located under 'Documents and Settings/User/Application Data/Adobe/Adobe Illustrator CS3 Settings'. It is a hidden file. Delete it with Illustrator closed and when you launch the program again the file will be rebuilt.
    May be it is also sounds like you need more memory for your computer. If you can navigate to your computer's memory controls, and allow your operating system to use a portion of your hard disk drive (HDD) as RAM (maybe 2Gb or so) it may solve your issue.
    How is about: http://www.filerepairforum.com/forum/adobe/adobe-aa/illustrator/383-%E2%80%8Bcorrupted-fon ts-in-illustrator-file-urgent-help-need – resource has non-commercial specialty
    Third party software Illustrator Repair Kit also must be good solution
    It has free demo version at:- http://www.illustrator.repair/
    Hope this will be helpful.

  • Problems with a Lenovo X41 and a docking station

    I have problems with a Lenovo X41 and the docking station.
    Sometimes, when the laptop is undocked and used in other location, when I try to dock it again, some devices, such as mouse or keyboeard attached to the docking station, don't work.
    I will appreciate your help.

    I am also having the same issue you describe.

Maybe you are looking for