Fastest way to select many rows?

I wonder way a simple select that only joins 2 tables take so long to execute. It takes up to 30 seconds to read 50.000 rows with the 9.2.0.5 driver on a ORACLE 8.0.5 server. In another project we read 100.000 rows with a similar select over two tables in 2 seconds on a MS SQL Server 7 with free jTDS JDBC driver.

You cannot directly compare the cost of two different queries. It is quite possible that a query with a cost of 100 will be significantly slower than a query with a cost of 1,000,000. Cost is generally meaningless outside of a very detailed CBO trace. In other words, for your purposes, you probably want to ignore the cost.
When you're looking at a query plan, the part that you ought to care about is the estimate of the number of rows that will be returned from a single step. If the value Oracle is estimating is significantly different than the value you know will be returned, that is an indicator that something may be amiss.
What is your OPTIMIZER_MODE set to? The CBO was in its infancy in 8.0.5, so you might want to try using the RBO instead (set OPTIMIZER_MODE to RULE). Advice for tuning queries on modern versions of Oracle is going to concentrate on making sure that the statistics for the CBO are accurate-- because you're on such an old version, you may be better off abandoning the CBO entirely.
When you time the queries, are you measuring the time it takes to return the first row? Or the last row?
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Easy Question:Select many rows from a table and execute BAPI for these rows

    Hi Experts,
    I have created one WD project. The WD project fetches some records of backend using BAPI and displays in a table. I have to select some rows from the table and then execute BAPI for selected rows.
    How I can select multiple records from the table and then execute another BAPI for selected rows.
    Regards,
    Gary

    Hi,
    In the Node which you binded to the table create one more attribute of type boolean.
    For example your node is as below:
    //Table Node
    TableNode
    > Att1
    > Att2
    > isSelected(boolean) - Newly created attribute for this requirement.
    //Result Node contains the elements selected in TableNode
    ResultNode
    >Att1
    >Att2
    Now in the table create one more Column with Checkbox as tablecell editor. Now bind this boolean attribute to that check box.
    Now in the code you can get the selected rows by user as below:
    for(int i=0;i<TableNode().size();i++)
      if(wdContext.nodeTableNode().getTableNodeElementAt(i).getIsSelected()==true)
        IPrivateTestView.IResultNode element=wdContext.createResultNodeElement();
        element.setAtt1(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt1());
        element.setAtt2(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt2());
       wdContext.nodeResultNode().addElement(element);
    Regards,
    Charan

  • What's the fastest way to select multiple side by side clips in an event?

    I want to select the bottom half of clips in an event so I can detach the audio. The only way I know how to do this is to hold down the command button as I select individual clips. There's gotta be an easier way! Is there a button (or buttons) I can hold down so that I can just drag over the clips I want to select? Alternatively, if there's a way I can just select the first clip, and then have it select every clip in between as I select the last clip, that would work too. Remember, I'm only selecting half of the clips, not all, and not all minus just a few, as I know easy ways to select all and also almost all clips.
    This is sooooo ridiculously basic that I can only conclude that either I am an idiot, or Apple puts their B-list developers in charge of this application, or both.
    Lastly if it's not too much to ask, can I get a woop woop!?

    It's the Shift key. It's not a button. It's shifts from lower case to upper case when typing. It's been called the Shift key since the 19th century.

  • In tabular form, is there a way to select one row as the default row?

    Hi, I have a tabular form which lists the many addresses that a fisherman may have. The query is: select default_addr_flag, addr1, addr2, city, state, zip from addresses where fisher_id = :PXX_fisher_id.
    I would like to have them set the default_addr_flag = 'Y' for ONLY ONE record....so even if they have many addresses, one must be selected as the default for any correspondence.
    Are there any examples, or does anyone have a suggestion. thank you!
    karen

    Hi Karen,
    I think first of all you should get yourself a browser and add-ons that allow you to inspect the HTML DOM elements. E.g. FF/Firebug/Error Console. Once you have the required tools you will be able to see for yourself what the DOM has, and then work out what you need to do.
    Most members, including myself, at times post solutions without really trying them out as they appear to be "obvious" even when they are not.
    Taking forward from the point where you have made the default address indication a "simple checkbox" from the Report Attributes tab, if you inspect the checkbox element you will find that it is somewhat more complex and Apex has created the elements with some JS code. E.g. this is a snippet from one of my application pages.
    <td headers="IS_CUSTOMER">
    <label class="hideMeButHearMe" for="f08_0001">Is Customer</label>
    <input type="checkbox" onclick="if (this.checked) {apex.jQuery('#f08_0001').val('Y');} else {apex.jQuery('#f08_0001').val('');}" id="f08_0001_01" checked="checked" value="Y" name="f08_NOSUBMIT" autocomplete="off">
    <input type="hidden" id="f08_0001" value="Y" name="f08" autocomplete="off">
    </td>You will see that
    a.Apex has created a onclick event trigger
    b. If sets the value of Unchecked checkbox to null ("").
    c. In my page the checkbox maps to f08, you need to see which item it maps to in your page.
    d. The id of the rendered checkbox is id of hidden element + _01.
    The consequence of this is that if you define a onclick trigger in the Element attributes it overrides and suppresses Apex from inserting its own JS code!
    To be able to uncheck all checkboxes other than the one the user has currently checked you will need to do this:
    i. In the Column's Element Attributes field write onclick="doDftAddr(this);"You could name the function the way you want it, this is an example.
    ii.In the Page HTML Header write
    <script type="text/javascript">
    function doDftAddr(pThis) {
      va = pThis.id.split("_");
      var vb = va[0]+'_'+va[1];
    if (pThis.checked) {
        vy = 'input:checked[id^="'+va[0]+'_"]'
        $("["+vy+"]").attr("checked",false);
        apex.jQuery("["+vy+"]").val('N');
        apex.jQuery('['+'input:hidden[id^="'+va[0]+'"_]'+']').val('N');
        apex.jQuery('#'+pThis.id).attr("checked",true);
        apex.jQuery('#'+pThis.id).val("Y");
        apex.jQuery('#'+vb).val('Y');
       } else {
        apex.jQuery('#'+vb).val('N');
    </script>Cheers,

  • Fastest way to select subset of a resultset?

    I have a query which I use to load a result set in Java 1,000 records each time., it looks like this:
    select DATA_CLOB as msg from
    (select DATA_CLOB, rownum as rn from msg_data where batch_id = ? and category = ? order by msg_data_id)
    where rn between ? and ?
    When the number of records for a given batch_id,category are small, say a few tens of thousands, its never been a problem
    But just recently it had to deal with one batch where there was 1.5 M records and this query is killing us, it's been 3 DAYS now and its not done yet!
    There are proper indexes on the columns selected from, and confirmed with Explain Plan that the plan is only doing indexed searches.
    Was the way we do the between 2 rownum indexes poor design?
    Is there a more efficient way?
    Other way I was thinking was maybe just do where rownum < 1000 each time instead of maintaining an index range which is incremented by a thousand each time.
    In either case I have both that select and an update which updates a timestamp on the rows that were processed, so I could use that in the where rownum < 1000 query to filter out rows already processed.
    Can you think of any other ways to do this quicker?
    Again, the sole purpose is to basically iterate through a subset of records from table, 1,000 at a time.

    trant wrote:
    I have a query which I use to load a result set in Java 1,000 records each time., it looks like this:
    select DATA_CLOB as msg from
    (select DATA_CLOB, rownum as rn from msg_data where batch_id = ? and category = ? order by msg_data_id)
    where rn between ? and ?
    When the number of records for a given batch_id,category are small, say a few tens of thousands, its never been a problem
    But just recently it had to deal with one batch where there was 1.5 M records and this query is killing us, it's been 3 DAYS now and its not done yet!Not surprising.
    It's having query all the data (including your CLOB data by the looks of it) and then order all that data before it picks out just the 1,000 rows you want.
    What is the business process you are trying to achieve by doing this?
    Seems odd that you want to query back 1,000 clobs of data at a time over the network to your java application.
    Other way I was thinking was maybe just do where rownum < 1000 each time instead of maintaining an index range which is incremented by a thousand each time.Still, if it's got to order the data first, it's going to take time.
    In either case I have both that select and an update which updates a timestamp on the rows that were processed, so I could use that in the where rownum < 1000 query to filter out rows already processed.
    Can you think of any other ways to do this quicker?
    Again, the sole purpose is to basically iterate through a subset of records from table, 1,000 at a time.Why? For what purpose?

  • Best way to load many rows on datagrid with MVVM?

    Hi,
    I have a table with more than 2 million rows and 20 columns. of course this takes so long to load the data on datagrid and even mostly causing out of memory exception. what kind of way can I follow to load this dynamically and efficiently? 
    In the attached project for example, in ordersview.xaml I am binding Orders as following. I guess that doing Async helps but not completly in my case. I need to find a kind of paging and background loading. Sample
    project doesnt have so many data but if possible to presume that there are so many Orders and i want to load all data. 
    <DataGrid Name="grdOrders" CopyingRowClipboardContent="DataGrid_CopyingRowClipboardContent" AutoGenerateColumns="False"
    ItemsSource="{Binding Orders, IsAsync=True}"
    protected async override void GetData( )
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

    I'll mention some complications first.
    If you keep a context alive, by default it will have change tracking for anything you read using it.  This is irrelevant if you read like 20 records.  Once you start talking many thousands, this if an overhead you want to avoid.
    A common dodge is to open a context, grab data, transform it elsewhere and then close the context.
    Work with your data disconnected.
    That means you lose change tracking but you can add such properties as IsDirty to a wrapping viewmodel so they each track their own changes.
    This isn't just about highlighting changed fields:
    https://gallery.technet.microsoft.com/WPF-Highlight-Changed-a77976d4
    Another dodge is to start off knowing what the user is probably interested in.
    I want todays newspaper, this months sales, yesterdays stock levels....
    People rarely actually want totally flexible filtering.
    Don't re-implement excel unless you really have to.
    You can filter huge collections, but you nothing is fr and if you put enough data into a collection thiDSDngs will slow. Eventually.
    But.  You can do date ranges.  Collectionview filtering can be persuaded to do pretty much anything you like by some variation of the filtering examples in those tips.
    For example, each of those predicates in the list to check can be quite complicated and you could go with .Any rather than trueforall.
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • Problem with select many rows in table

    1. I have af:table
    2. In my bean I get the selected rows with
    DCIteratorBinding countriesIterator =
    ADFUtils.findIterator("FigureTypesViewIterator");
    RowKeySet rowSet = this.getRichTable().getSelectedRowKeys();
    Iterator rowSetIterator = rowSet.iterator();
    But I get only the last selected row. Any suggestions ?
    <af:table value="#{bindings.FigureTypesView.collectionModel}" var="row"
    rows="#{bindings.FigureTypesView.rangeSize}"
    first="#{bindings.FigureTypesView.rangeStart}"
    emptyText="#{bindings.FigureTypesView.viewable ? 'No rows yet.' : 'Access Denied.'}"
    fetchSize="#{bindings.FigureTypesView.rangeSize}"
    selectedRowKeys="#{bindings.FigureTypesView.collectionModel.selectedRow}"
    selectionListener="#{bindings.FigureTypesView.collectionModel.makeCurrent}"
    rowSelection="multiple"
    binding="#{PeopleSelectManyLOVBean.richTable}">

    Zaro,
    To get a table to work correctly for multiple selection following changes need to be made
    1. Set property 'rowSelection' to multiple.
    2. Remove property 'selectedRowKeys'.
    3. Remove property 'selectedListener'.
    4. Remove property 'selectedState'.
    Only then does the multi select work correctly.
    HTH,
    --AJ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Data Merge - Is there a way to selectively hide rows/columns from layouts based on cell values?

    I'm using data merge to generate pages from a product spreadsheet. The complication is, some columns should exist for some products (like "qty per bundle") but need to be hidden for others. Is there a way for InDesign to automatically include or remove rows for some pages but not others, based on something like "qty = 0"?

    For logic-based data merge, I use Em Software's product InData.
    Depending upon the design, ID's merge can remove blank fields thereby removing there paragraph or position on a line. Unless, of course, you have static text along with it. Which I almost always do. that's why I use Em Software's solution. It has a trial version. One needs to get familiar with the language statements. But for me it was worth the price and learning curve.
    And there are other plug-ins but for "simple" merging they are overkill in my circumstances (and so cost more).
    Mike

  • Is this the fastest way to insert 100k rows into a database?

    I'm looking to insert ~100k rows into a database as fast as possible. I'm connected to the database through a small LAN with static IP adresses. The target database is running my SQL. Here's the fastest I've gotten the code so far. Task manager shows that it's only sending like 2.5mbps. If I take the size of the 2D array (64MB) and divide by the time it takes to transfer it currently, I calculate ~160kbps. Is that the best I can hope for with the NI DB Toolkit?
    CLD (2014)

    Hi,
    Use DB Tool Insert Data VI to insert the data in the database.
    You can insert complete row data at a time. No need to insert single-single element in database this will reduce your code performance.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!

  • Copying many rows from one table to another

    Could anyone tell me the best way to copy many rows (~1,000,000) from one table to another?
    I have supplied a snipit of code that is currently being used in our application. I know that this is probably the slowest method to copy the data, but I am not sure what the best way is to proceed. I was thinking that using BULK COLLECT would be better, but I do not know what would happen to the ROLLBACK segment if I did this. Also, should I look at disabling the indexes while the copy is taking place, and then re-enable them after it is complete?
    Sample of code currently being used:
    PROCEDURE Save_Data
    IS
    CURSOR SCursor IS
    SELECT     ROWID Row_ID
    FROM     TMP_SALES_SUMR tmp
    WHERE NOT EXISTS
    (SELECT 1
         FROM SALES_SUMR
         WHERE sales_ord_no = tmp.sales_ord_no
         AND cat_no = tmp.cat_no
         AND cost_method_cd = tmp.cost_method_cd);
    BEGIN
    FOR SaveRec IN SCursor LOOP
    INSERT INTO SALES_ORD_COST_SUMR
    SELECT *
    FROM TMP_SALES_ORD_COST_SUMR
    WHERE ROWID = SaveRec.Row_ID;
    RowCountCommit(); -- Performs a Commit for every xxxx rows
    END LOOP;
    COMMIT;
    EXCEPTION
    END Save_Data;
    This type of logic is used to copy data for about 8 different tables, each containing approximately 1,000,000 rows of data.

    Your best bet is
    Insert into SALES_ORD_COST_SUMR
    select * from TMP_SALES_ORD_COST_SUMR;
    commit;
    Read this
    http://asktom.oracle.com/pls/ask/f?p=4950:8:15324326393226650969::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:5918938803188
    VG

  • How to select multiple rows from List Of Values

    Hello,
    I use ADF 11g to create my list of values (LOV). I want to select multiple rows from it. but i can't.
    so how i can select many rows to set them in my adf table.
    Thank in advance

    Hi,
    LOV is map to an attribute in the viewObject so it will return only one value or more values from selected row. You can't select multiple rows from LOV.
    But you can do this by using popup which you can select multiple rows and insert the selected rows to another table.
    This blog post explain how to achieve this :
    http://husaindalal.blogspot.com/2009/11/search-from-popup-and-add-to-new-table.html#comments
    Sameh Nassar

  • Af:inputListOfValues popup : selecting first row

    Hi,
    Is there a way to select first row inside lov popup, the by default behaviour is it selects the rowHeader rather than row itself.
    When the lov popup is opened , there is no focus on table resides in the popup
    - to focus on table, user has to press down arrow key - which will just focus on rowHeader and not the actual row itself
    - to focus row for currently selected rowHeader user has to press right arrow key which will then select the table row itself
    its cumbersome everytime when you open lov and do these extra steps to just to select a value from lov
    any ideas?
    Thanks,
    Dev

    so, why it supports keyboard navigation at all? either support full features or nothing. the fact that user can use up/down arrow keys which selects rowHeader of every row , rather than actual row
    regarding "Search and Select : " it could be anything it has nothing to do with row selection,
    Thanks,

  • Programmatically select multiple rows in DataGrid

    Hello,
    I'm trying to do it for days. How can i select many rows in my DataGrid in the code. In my DataGrid i have rows responsible for folders and files - existing in these folders. When user selects folder row i want to select all rows responsible for files that
    are in that folder. Of course i know which rows should be selected, but the problem is how to do it? I can add that my DataGrid is Binded to ObservableCollection(containing strings with pathes to different directories and files. Please some help.

    Hi Josef,
    I am marking this issue as "Answered". If you have any new questions or concerns about this issue, please feel free to let me know.
    Thank you and have a nice day!
    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • How to efficiently select random rows from a large table ?

    Hello,
    The following code will select 5 rows out of a random set of rows from the emp (employee) table
    select *
      from (
           select ename, job
             from emp
           order by dbms_random.value()
    where rownum <= 5my concern is that the inner select will cause a table scan in order to assign a random value to each row. This code when used against a large table can be a performance problem.
    Is there an efficient way of selecting random rows from a table without having to do a table scan ? (I am new to Oracle, therefore it is possible that I am missing a very simple way to perform this task.)
    thank you for your help,
    John.
    Edited by: 440bx on Jul 10, 2010 6:18 PM

    Have a look at the SAMPLE clause of the select statement. The number in parenthesis is a percentage of the table.
    SQL> create table t as select * from dba_objects;
    Table created.
    SQL> explain plan for select * from t sample (1);
    Explained.
    SQL> @xp
    PLAN_TABLE_OUTPUT
    Plan hash value: 2767392432
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |   725 | 70325 |   289   (1)| 00:00:04 |
    |   1 |  TABLE ACCESS SAMPLE| T    |   725 | 70325 |   289   (1)| 00:00:04 |
    8 rows selected.

  • Is there an easy way to see how many rows in a table? (selected or unselected)

    Hi all,
    Forgive me if this is a REALLY dumb question but I would love to know if there there is an easy way to to see how many rows there are in a table in InDesign?
    (And I bet I am really going to kick myself when I hear the answer and how simple it probably is..lol !)
    I am working on a huge catalog and am dealing with LOTS of tables...very long tables too at times. I am also doing a lot of copying and pasting back and forth between InDesign and Excel and it would REALLY help if I knew how many rows there are in a table without having to manually count them (TIRESOME!!).
    Also, is there a way to see how many rows I have selected at any one time? It would be SO WONDERFUL if the info box could also provide this information.
    Thank you SO MUCH in advance for your help:))
    Christine
    **UPDATE**
    Oh boy I AM going to kick myself! Why only NOW that I wrote this question did I suddenly notice that the Table palette shows the number of rows and columns? lol.
    Okay, then is there a way to see how many rows I have selected at any given time?

    @Christine – try the following ExtendScript (JavaScript):
    if(app.selection.length === 0
        || !app.selection[0].constructor.name === "Cell"
        || !app.selection[0].constructor.name === "Table"){
        exit(0);
    var sel = app.selection[0];
    if(sel.constructor.name === "Cell"){
        var tableRowLength = sel.parent.rows.everyItem().getElements().length;
    if(sel.constructor.name === "Table"){
        alert("All "+sel.rows.everyItem().getElements().length+" rows selected in current table." );
        exit(0);
    var numberOfRowsSelected = sel.rows.length;
    var indexOfSelectedRows = sel.rows.everyItem().index;
    var startRowSel = indexOfSelectedRows[0]+1;
    var endRowSel = indexOfSelectedRows.length+indexOfSelectedRows[0];
    alert(numberOfRowsSelected +" row(s) selected.\r"+startRowSel+" to "+endRowSel+" out of "+tableRowLength+" of current table.");
    You need not select whole rows, just one or a couple of cells.
    Then run the script.
    An alert message is telling you how many rows belong to the cell range you have selected and:
    which rows of the table are selected…
    A typical message would be:
    6 row(s) selected.
    3 to 8 out of 20 of current table.
    The script does some basic checks of the selection.
    If no cell or table is selected, it will just do nothing…
    Uwe
    Message was edited by: Laubender | Some language cosmetics in the alert message

Maybe you are looking for

  • Stream photos in the same itunes library used to syinc.

    It's possible or not ? Have sync photos in apple tv and want to see some stream photos in the same library

  • Rendering a PDF/Mime Type in cfDIV

    Hi there I have a cfform that looks at files in a directory. The template is meant to allow users to select a document and and view it on the page. The relevant code is: Main Page: <cfform name = "name"> <cfinput name="displayName"  id="displayName"

  • Is Oracle planning to continue oo4o?

    I'm new (2 months) to oo4o, having inherited a project that uses it extensively. Does anyone know what Oracle's plans are for oo4o? I see there's a version for 9i, which bodes well. Any input is appreciated. Thanks.

  • Colors Inconsistent Despite Profiles

    Running CS5 - I set up the color profiles in Bridge so that they would be consistent across all CS5 programs, yet colors (even PMS) look quite different between Illustrator and Photoshop. please advise

  • Forms & Reports Runtime Package

    Hello, I have a network of 250+ nodes with client server environment. To enable users to use in-hous developed business applications, it requires to install Forms & Report Runtime on these 250+ PCs which is a tedius job. Is there any utility (like wi