Nested loops

Hello

A fundamental question about Nested Loops, what is the number of rows in the inner table means (4 in this example)? This is the average number of lines that oracle had to read by loop?

Thank you.
SYS> SHOW PARAMETER optimizer_features_enable

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
optimizer_features_enable            string      11.2.0.1

HR> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER , 'EMPLOYEES' , CASCADE => TRUE )

PL/SQL procedure successfully completed.

HR> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER , 'DEPARTMENTS' , CASCADE => TRUE )

PL/SQL procedure successfully completed.

HR> SELECT COUNT(*) FROM employees ;

  COUNT(*)
----------
       107

HR> SELECT COUNT(*) FROM departments ;

  COUNT(*)
----------
        27

SELECT /*+ USE_NL(e d) */ e.last_name , d.department_name
 FROM employees e , departments d
 WHERE e.department_id = d.department_id;

Execution Plan
----------------------------------------------------------
Plan hash value: 2968905875

------------------------------------------------------------------
| Id  | Operation          | Name        | Rows  | Bytes | Cost  |
------------------------------------------------------------------
|   0 | SELECT STATEMENT   |             |   106 |  2862 |    24 |
|   1 |  NESTED LOOPS      |             |   106 |  2862 |    24 |
|   2 |   TABLE ACCESS FULL| DEPARTMENTS |    27 |   432 |     2 |
|*  3 |   TABLE ACCESS FULL| EMPLOYEES   |     *4* |    44 |     1 |
------------------------------------------------------------------

Hello

A fundamental question about Nested Loops, what is the number of rows in the inner table means (4 in this example)? This is the average number of lines that oracle had to read by loop?

Hello

in fact, it's exactly what it is, with the exception of is not the true Oracle number was read, it is an estimate.

You can track 10053 and see how the optimizer reach these numbers. The optimizer calculates the cardinality of the join using the following formula:

cardinality (employees) * *(join selectivity) cardinality (departments).

and join selectivity is essentially 1/greater (num_distinct (departments.department_id), (departments.department_id) num_distinct), adjusted for null values (not NULL values in this particular case, so no adjustment is necessary).

If you plug the values you get for the cardinality of the join:

107 * 27 * join selectivity, which join selectivity = 1/greater(11, 27) = 1/27 = 0.036691, so 107 * 27 * 0.036 ~ = 106.

4 comes from this number by dividing the cardinality expected join (106) by the estimated number of iterations of the nested loop (27).

It is not true the optimizer assumes an even distribution here - if it did, then it should get to 11 employees by Department, not 4 (because num_distinct (employees.department_id) = 11, not 4).

If you are interested in these issues, please refer to the excellent book by Jonathan Lewis "Cost based fundamentals", is all explained quite well in there.

Best regards
Nikolai

Tags: Database

Similar Questions

  • Variable and nested loops

    Hi, I'm a relatively new to programming of LV, so be gentle.

    In a Word, I am running nested loops than the material test power on and off cycles. The parameters for each loop is entered on the front panel of the user. For example, the power supply at the time, how many times to read in the data, power supply off time and the number of cycles power is a typical customer task ask me to do. Therefore, I decided to do a generic as possible executable vi instead of writing code (in which I request is trivial), that my technicians can easily use.

    I want to put a counter - down in this vi, even a journey of one. I'll take the more the off time multiplied by the number of cycles and display on the front panel. For some reason that I can't find a simple way such that when the last cycle ended if poster zero before the program ends.

    For example, the total is equal to 60 minutes and 10-minute cycle. I run the program and the display shows 60 during the first cycle, after the first cycle is complete and the second cycle begins the display turns 50, and so on until that last cycle where you can read 10. Then the program ends and the screen 10. How can I get a last beat of this kind it says 0 and 0 poster before the end of the program?

    Thank you!

    Wire a zero to a local variable of this indicator so that it can turn when the while loop ends.

  • Save several bays of nested loops

    Hello

    My vi generates several bays in each iteration of the loop, and I would like to save the data. I did work with the files before recording, but it's never with nested loops. I don't know how to keep the information of the iteration of one loop at the other. I would like suggestions. I made this sample & simple vi (attached file) that simulates the question I have. I have a file with a time column and different columns of food beside him.

    The first question I have is that I generate the time table only once, but a table of signal several times, so how can I keep the time table to drop several times? The other question, as stated above, saves the data in the table signal getting lost in the nested loops...

    Thank you

    A

    1. the first element of the first matrix signal IS always zero.  The Signal to simulate always starts at zero.  You compare it to the indicator of "first date".  Who got by converting the dynamic data type to a scalar.  And it's always the last element of the actual data.  And since the "first out" is replaced with each iteration of the inner loop, the number you see at the end is actually the latest iteration of the data.  Look at "First release" in comparison with the last element of your last column of the table and you will see they are the same.

    2. the reason why you have a first column that consists of the steps is because that's what you have wired to initialize the shift register.  If you look at my example, you will see that I have an empty array.  (The zero is gray.)  You, the 0 is not dimmed meaning there is an element.  Expand this table to view more items and expand the digital field and you will see more digits.  They correspond to what is in your first column.

  • use OPT_ESTIMATE or CARDINALITY tip for correct estimation of nested loops

    I'm using Oracle 11.2.0.3.  Below the execution below plan, how can I use tip OPT_ESTIMATE or CARDINALITY to teach optimization E-lines for ID 9 (Nested Loop) 30553 instead of 6.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                   | Name                        | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                            |                             |      1 |        |       |  4604 (100)|          |  30553 |00:00:02.56 |     208K|       |       |          |
    |   1 |  SORT ORDER BY                              |                             |      1 |      6 |  7044 |  4604   (1)| 00:01:05 |  30553 |00:00:02.56 |     208K|    41M|  2086K|   36M (0)|
    |*  2 |   HASH JOIN OUTER                           |                             |      1 |      6 |  7044 |  4603   (1)| 00:01:05 |  30553 |00:00:02.10 |     208K|    38M|  3120K|   39M (0)|
    |*  3 |    HASH JOIN OUTER                          |                             |      1 |      6 |  6870 |  4599   (1)| 00:01:05 |  30553 |00:00:01.97 |     208K|    38M|  3120K|   39M (0)|
    |*  4 |     HASH JOIN OUTER                         |                             |      1 |      6 |  6744 |  4591   (1)| 00:01:05 |  30553 |00:00:01.85 |     208K|    37M|  3121K|   39M (0)|
    |*  5 |      HASH JOIN OUTER                        |                             |      1 |      6 |  6570 |  4584   (1)| 00:01:05 |  30553 |00:00:01.74 |     208K|    37M|  3121K|   38M (0)|
    |*  6 |       HASH JOIN OUTER                       |                             |      1 |      6 |  6414 |  4576   (1)| 00:01:05 |  30553 |00:00:01.60 |     208K|    37M|  3121K|   38M (0)|
    |   7 |        NESTED LOOPS                         |                             |      1 |        |       |            |          |  30553 |00:00:01.44 |     208K|       |       |          |
    |   8 |         NESTED LOOPS                        |                             |      1 |      6 |  6318 |  4572   (1)| 00:01:05 |  30553 |00:00:01.31 |     182K|       |       |          |
    |   9 |          NESTED LOOPS                       |                             |      1 |      6 |  1830 |  4568   (1)| 00:01:04 |  30553 |00:00:01.11 |     124K|       |       |          |
    |* 10 |           HASH JOIN                         |                             |      1 |   2069 |   270K|  2499   (1)| 00:00:35 |  30646 |00:00:00.46 |   23738 |  6539K|  2033K| 7965K (0)|
    |* 11 |            TABLE ACCESS BY INDEX ROWID      | DSCLR                       |      1 |   5079 |   158K|   533   (1)| 00:00:08 |  91395 |00:00:00.28 |    6460 |       |       |          |
    |  12 |             BITMAP CONVERSION TO ROWIDS     |                             |      1 |        |       |            |          |    197K|00:00:00.16 |     615 |       |       |          |
    |  13 |              BITMAP AND                     |                             |      1 |        |       |            |          |      4 |00:00:00.14 |     615 |       |       |          |
    |  14 |               BITMAP OR                     |                             |      1 |        |       |            |          |      4 |00:00:00.07 |     276 |       |       |          |
    |  15 |                BITMAP CONVERSION FROM ROWIDS|                             |      1 |        |       |            |          |      2 |00:00:00.02 |      69 |       |       |          |
    |* 16 |                 INDEX RANGE SCAN            | XIF913DSCLR                 |      1 |    274K|       |    14   (0)| 00:00:01 |  68407 |00:00:00.01 |      69 |       |       |          |
    |  17 |                BITMAP CONVERSION FROM ROWIDS|                             |      1 |        |       |            |          |      4 |00:00:00.05 |     207 |       |       |          |
    |* 18 |                 INDEX RANGE SCAN            | XIF913DSCLR                 |      1 |    274K|       |    42   (0)| 00:00:01 |    209K|00:00:00.03 |     207 |       |       |          |
    |  19 |               BITMAP CONVERSION FROM ROWIDS |                             |      1 |        |       |            |          |      5 |00:00:00.06 |     339 |       |       |          |
    |* 20 |                INDEX RANGE SCAN             | XIF910DSCLR                 |      1 |    274K|       |    67   (0)| 00:00:01 |    239K|00:00:00.04 |     339 |       |       |          |
    |  21 |            NESTED LOOPS                     |                             |      1 |        |       |            |          |  21749 |00:00:00.10 |   17278 |       |       |          |
    |  22 |             NESTED LOOPS                    |                             |      1 |   3404 |   339K|  1965   (1)| 00:00:28 |  22772 |00:00:00.03 |    1246 |       |       |          |
    |  23 |              TABLE ACCESS FULL              | TMP_RPT_BD_STATE_DATA_DWNLD |      1 |   3255 |   257K|    11   (0)| 00:00:01 |   3255 |00:00:00.01 |      27 |       |       |          |
    |* 24 |              INDEX RANGE SCAN               | XIE2OCRN                    |   3255 |      7 |       |     1   (0)| 00:00:01 |  22772 |00:00:00.03 |    1219 |       |       |          |
    |* 25 |             TABLE ACCESS BY INDEX ROWID     | OCRN                        |  22772 |      1 |    21 |     1   (0)| 00:00:01 |  21749 |00:00:00.06 |   16032 |       |       |          |
    |* 26 |           VIEW PUSHED PREDICATE             |                             |  30646 |      1 |   171 |     1   (0)| 00:00:01 |  30553 |00:00:00.63 |     101K|       |       |          |
    |  27 |            WINDOW BUFFER                    |                             |  30646 |      1 |    21 |     1   (0)| 00:00:01 |  46946 |00:00:00.59 |     101K|  2048 |  2048 | 2048  (0)|
    |* 28 |             TABLE ACCESS BY INDEX ROWID     | DSCLR_FLNG                  |  30646 |      1 |    21 |     1   (0)| 00:00:01 |  46946 |00:00:00.32 |     101K|       |       |          |
    |* 29 |              INDEX RANGE SCAN               | XIE1DSCLR_FLNG              |  30646 |      2 |       |     1   (0)| 00:00:01 |  46946 |00:00:00.21 |   59862 |       |       |          |
    |* 30 |          INDEX RANGE SCAN                   | XPKH760_RGLTY_ACTN_DSCLR    |  30553 |      1 |       |     1   (0)| 00:00:01 |  30553 |00:00:00.18 |   57541 |       |       |          |
    |  31 |         TABLE ACCESS BY INDEX ROWID         | H760_RGLTY_ACTN_DSCLR       |  30553 |      1 |   748 |     1   (0)| 00:00:01 |  30553 |00:00:00.11 |   26218 |       |       |          |
    |  32 |        TABLE ACCESS FULL                    | DSCLR_ST_TYPE_TBL           |      1 |      4 |    64 |     4   (0)| 00:00:01 |      4 |00:00:00.01 |       5 |       |       |          |
    |  33 |       TABLE ACCESS FULL                     | RGLTY_RSLTN_TYPE_TBL        |      1 |     12 |   312 |     7   (0)| 00:00:01 |     12 |00:00:00.01 |      10 |       |       |          |
    |  34 |      TABLE ACCESS FULL                      | INTTR_TYPE_TBL              |      1 |     14 |   406 |     7   (0)| 00:00:01 |     14 |00:00:00.01 |      10 |       |       |          |
    |  35 |     TABLE ACCESS FULL                       | SNCTN_TYPE_TBL              |      1 |     15 |   315 |     7   (0)| 00:00:01 |     15 |00:00:00.01 |      10 |       |       |          |
    |  36 |    TABLE ACCESS FULL                        | PRDCT_TYPE_TBL              |      1 |     25 |   725 |     4   (0)| 00:00:01 |     25 |00:00:00.01 |       5 |       |       |          |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Query Block Name / Object Alias (identified by operation id):
    -------------------------------------------------------------
    
       1 - SEL$A8B7A3F4
      11 - SEL$A8B7A3F4 / [email protected]$13
      23 - SEL$A8B7A3F4 / [email protected]$1
      24 - SEL$A8B7A3F4 / [email protected]$13
      25 - SEL$A8B7A3F4 / [email protected]$13
      26 - SEL$13512960 / [email protected]$13
      27 - SEL$13512960
      28 - SEL$13512960 / [email protected]$14
      29 - SEL$13512960 / [email protected]$14
      30 - SEL$A8B7A3F4 / [email protected]$2
      31 - SEL$A8B7A3F4 / [email protected]$2
      32 - SEL$A8B7A3F4 / [email protected]$9
      33 - SEL$A8B7A3F4 / [email protected]$11
      34 - SEL$A8B7A3F4 / [email protected]$3
      35 - SEL$A8B7A3F4 / [email protected]$5
      36 - SEL$A8B7A3F4 / [email protected]$7
    
    Outline Data
    -------------
    
      /*+
          BEGIN_OUTLINE_DATA
          IGNORE_OPTIM_EMBEDDED_HINTS
          OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
          DB_VERSION('11.2.0.3')
          OPT_PARAM('optimizer_index_cost_adj' 20)
          ALL_ROWS
          OUTLINE_LEAF(@"SEL$13512960")
          PUSH_PRED(@"SEL$A8B7A3F4" "DF"@"SEL$13" 11)
          OUTLINE_LEAF(@"SEL$A8B7A3F4")
          ELIMINATE_JOIN(@"SEL$2D47CDEA" "DTT"@"SEL$13")
          OUTLINE(@"SEL$14")
          OUTLINE(@"SEL$A8B7A3F4")
          ELIMINATE_JOIN(@"SEL$2D47CDEA" "DTT"@"SEL$13")
          OUTLINE(@"SEL$2D47CDEA")
          MERGE(@"SEL$3FAACB6D")
          OUTLINE(@"SEL$15")
          OUTLINE(@"SEL$3FAACB6D")
          MERGE(@"SEL$11")
          MERGE(@"SEL$A1A6E401")
          OUTLINE(@"SEL$12")
          OUTLINE(@"SEL$11")
          OUTLINE(@"SEL$A1A6E401")
          MERGE(@"SEL$9")
          MERGE(@"SEL$BFB1842A")
          OUTLINE(@"SEL$10")
          OUTLINE(@"SEL$9")
          OUTLINE(@"SEL$BFB1842A")
          MERGE(@"SEL$7")
          MERGE(@"SEL$EEDE2B8C")
          OUTLINE(@"SEL$8")
          OUTLINE(@"SEL$7")
          OUTLINE(@"SEL$EEDE2B8C")
          MERGE(@"SEL$5")
          MERGE(@"SEL$A6B38458")
          OUTLINE(@"SEL$6")
          OUTLINE(@"SEL$5")
          OUTLINE(@"SEL$A6B38458")
          MERGE(@"SEL$171BE69E")
          MERGE(@"SEL$3")
          OUTLINE(@"SEL$4")
          OUTLINE(@"SEL$171BE69E")
          MERGE(@"SEL$AF02BF1E")
          OUTLINE(@"SEL$3")
          OUTLINE(@"SEL$2")
          OUTLINE(@"SEL$AF02BF1E")
          MERGE(@"SEL$13")
          OUTLINE(@"SEL$1")
          OUTLINE(@"SEL$13")
          FULL(@"SEL$A8B7A3F4" "OH"@"SEL$1")
          INDEX(@"SEL$A8B7A3F4" "O"@"SEL$13" ("OCRN"."ORG_PK" "OCRN"."DSCLR_DSCLB_FL" "OCRN"."DSCLR_RPTBL_FL"))
          BITMAP_TREE(@"SEL$A8B7A3F4" "D"@"SEL$13" AND(OR(1 1 ("DSCLR"."FORM_TYPE_CD") 2 ("DSCLR"."FORM_TYPE_CD")) ("DSCLR"."DSCLR_TYPE_CD")))
          NO_ACCESS(@"SEL$A8B7A3F4" "DF"@"SEL$13")
          INDEX(@"SEL$A8B7A3F4" "H7"@"SEL$2" ("H760_RGLTY_ACTN_DSCLR"."FLNG_PK" "H760_RGLTY_ACTN_DSCLR"."DSCLR_PK" "H760_RGLTY_ACTN_DSCLR"."REC_SEQ_NB"))
          FULL(@"SEL$A8B7A3F4" "DS"@"SEL$9")
          FULL(@"SEL$A8B7A3F4" "RST"@"SEL$11")
          FULL(@"SEL$A8B7A3F4" "ITT"@"SEL$3")
          FULL(@"SEL$A8B7A3F4" "ST"@"SEL$5")
          FULL(@"SEL$A8B7A3F4" "PT"@"SEL$7")
          LEADING(@"SEL$A8B7A3F4" "OH"@"SEL$1" "O"@"SEL$13" "D"@"SEL$13" "DF"@"SEL$13" "H7"@"SEL$2" "DS"@"SEL$9" "RST"@"SEL$11" "ITT"@"SEL$3" "ST"@"SEL$5" "PT"@"SEL$7")
          USE_NL(@"SEL$A8B7A3F4" "O"@"SEL$13")
          NLJ_BATCHING(@"SEL$A8B7A3F4" "O"@"SEL$13")
          USE_HASH(@"SEL$A8B7A3F4" "D"@"SEL$13")
          USE_NL(@"SEL$A8B7A3F4" "DF"@"SEL$13")
          USE_NL(@"SEL$A8B7A3F4" "H7"@"SEL$2")
          NLJ_BATCHING(@"SEL$A8B7A3F4" "H7"@"SEL$2")
          USE_HASH(@"SEL$A8B7A3F4" "DS"@"SEL$9")
          USE_HASH(@"SEL$A8B7A3F4" "RST"@"SEL$11")
          USE_HASH(@"SEL$A8B7A3F4" "ITT"@"SEL$3")
          USE_HASH(@"SEL$A8B7A3F4" "ST"@"SEL$5")
          USE_HASH(@"SEL$A8B7A3F4" "PT"@"SEL$7")
          SWAP_JOIN_INPUTS(@"SEL$A8B7A3F4" "D"@"SEL$13")
          INDEX_RS_ASC(@"SEL$13512960" "DF1"@"SEL$14" ("DSCLR_FLNG"."DSCLR_PK" "DSCLR_FLNG"."BLLBL_FL"))
          END_OUTLINE_DATA
      */
    

    This plan gives you an idea of why your initial synchronization has been long - most of your readings are one-piece readings and you have read 53 724 blocks. If you estimate 1 centisecond by read (which could be on a reasonable charge system) then it is 537 seconds. to 5 milliseconds per read, it's still 268 seconds or 4 minutes and 30 seconds.

    A quick break down of some (the worst case) potential time - only you can say whether or not some of these readings will be always/often/never being cached in the file or at the SAN level.

    Line 11 - physical reads 6 400 done - it's a tree bitmap then the readings are in the order of physical table with no. rereads. Call 5ms by read-online 32 seconds. L

    | * 11 |            TABLE ACCESS BY INDEX ROWID | DSCLR                       |      1.   5079.   158K |   533 (1) | 00:00:08 |  91395 | 00:00:01.27 |    6460.   6400 |       |       |          |

    The hash join takes us from 6 400 to 11 788 because it joins, lines 21 to 25 (nested loop) in which most of the work is the random access table with some automatic caching: 26 seconds. Do a search here rather than indexed 22 000 access? Which would be faster, which would charge less.

    | * 25.             TABLE ACCESS BY INDEX ROWID | OCRN                        |  22050.      1.    21.     1 (0) | 00:00:01 |  21059 | 00:01:04.74 |   15634 |   5280.       |       |          |

    Three nested loops that introduce more readings:

    11788 9-> 26386:14 600 of the predicate view pushed which some lies but a very large index and a table of random access 73 seconds

    8 26386-> 33783:7 400 index line 30 - big clue about 37 seconds Access hides

    33783 7-> 53691:19 900 31 table access - large table line, not much caching, 100 seconds.

    In each case, you can ask if an analysis would take less time than all of these random reads.

    NOTE - all I'm pointing our here where you potentially use a lot of time so that you can ask whether or not you should do little of the query in this way, or if there is an alternative, or if the work you're doing is absolutely necessary. If you want to optimize the query you should consider the intent of the query and think your way through a reasonable join order to see if you can imagine an effective way to get the same data. I have written a few articles and presentation on an approach that begins by drawing - here is a link to an article I wrote for a group of SQL Server: https://www.simple-talk.com/sql/performance/designing-efficient-sql-a-visual-approach/

    and a video I did with Kyle Hailey, while he was working for Embarcadero:Tune in for the ultimate SQL Tune-off | Landing pages

    Concerning

    Jonathan Lewis

  • Need help for the conversion of the nested loops to use the stream

    I'm trying to teach me how to effectively use the java stream, but finds it difficult to find the correct syntax for a problem of nested loop. I would like to convert the following code to use the Java 8 stream instead of nested loops.  Can anyone provide an example or a solution?

     /**
         * Return all members of stringListOne that begin with any of the strings in
         * stringListTwo
         *
         * @return all members of stringListOne that begin with any of the strings in
         * stringListTwo
         */
        Set<String> getFilteredStrings(Set<String> stringListOne, Set<String> stringListTwo) {
         
          Set<String> stringListOneFiltered = new HashSet<String>();
          for (String next : stringListOne) {
                for (String nextPrefix : stringListTwo) {
                    if (next.startsWith(nextPrefix)) {
                        stringListOneFiltered.add(next);
                    }
                }
            }
            return stringListOneFiltered;
        }
    

    Here's a test case for the above code:

    /**
         * Test method for {@link scratchpad.MyClass#getFilteredStrings(java.util.Set, java.util.Set)}.
         */
        @Test
        public final void testGetFilteredStrings() {
    
            MyClass uut = new MyClass();
            
            Set<String> stringListOne = new HashSet<String>();
            stringListOne.add("until");
            stringListOne.add("unite");
            stringListOne.add("under");
            stringListOne.add("prepare");
            stringListOne.add("pretend");
            stringListOne.add("prefix");
            stringListOne.add("prepend");
            stringListOne.add("post");
            stringListOne.add("positive");
            stringListOne.add("postgame");
            stringListOne.add("postpone");       
            
            Set<String> stringListTwo = new HashSet<String>();
            stringListTwo.add("post");
            stringListTwo.add("pre");
            stringListTwo.add("und");
            
            
            Set<String> result= uut.getFilteredStrings(stringListOne, stringListTwo);
            
            System.out.println(result);
            assertEquals(8, result.size());
        }
    

    Thanks for any help you can provide!  I get the hang of using the course of water, but this particular code was difficult.

    tmbc

    I found the following solution to my question:

    GetFilteredStrings (Set stringListOne, the value

    {Set stringListTwo)

    Predicate startsWith = p-> stringListTwo.stream () .anyMatch (prefix-> p.startsWith (prefix));

    Return stringListOne.stream () .filter (startsWith) .collect (Collectors.toSet ());

    }

  • Help to find the best way to interior design (Nested Loops of sliders?)

    Oracle 11G

    First here the table I work with, for example data

    ID FID ANNOTATION DESIGNATION LOW HIGH SEQ
    11008755360FC1053, 81-82FC105381821
    21008755360XD, 3-24XD3242
    31008756293FC1053, 81-82FC105381821
    41008756293XD, 3-24XD3242

    Each FID is a different line, these two lines are connected physically, that's why I've shown them here on the table. Each line has a 'meter', in this case, each line has 2 lines of account that are the same.

    cableExample.png

    From there, we can say that FC1053, 81 and 82 are connected between the 2 cables. XD DESIGNATION means that cables are connect not really so I can't ignore those.

    We have a different way to show that they connect other than only those data and I need to connect each other too much. For this I need the Info

    FID1 LOW HIGH FID2
    100875536081821008756293

    So my first design was the hepatitis hase sliders 2 with the data in the table, as shown above. I would then have a nested loop. The first slider to select the first record, then go down to the second loop where I compare all other records the first record and then go back in the outer loop to move to the next record, then return once again to the inner loop to compare the values again.

    LOOP1

    LOOP 2

    If LOOP1. IDF! LOOP2 =. IDF THEN

    IF LOOP1. ANNOTATION = LOOP2. ANNOTATION THEN

    -CONNECT THE DATA

    ON THE OTHER

    IF LOOP1. DESCRIPTION = LOOP2. DESIGNATION THEN

    IF LOOP2. LOW BETWEEN LOOP1. LOW AND LOOP1. THEN HIGH

    IF LOOP2. HIGH BETWEEN LOOP1. LOW AND LOOP1. HGH THEN

    -CONNECT THE DATA

    END IF;

    END IF;

    END IF;

    END IF;

    END IF;

    END LOOP;

    -Open and close done to reset the cursor to the front/top

    CLOSE CURSOR LOOP2;

    OPEN CURSOR LOOP2

    END LOOP;

    The problem with this approach is once the outside loop moves the next value of the IDF, that logic will connect them once again, but this time with the FIDs reverse which is essentially the same thing as it does not matter the direction in which they are connected. I almost feel that once I found the link I need to remove that line from the cursor (which isn't possible).

    FID1 LOW HIGH FID2
    100875536081821008756293
    100875629381821008755360

    I was able to

    1. make a list of all those I have connected and check against that

    2 use some kind of collection

    3. use a temporary table to hold the data

    4 something that I have not yet thought

    I really appreciate in advance for any help I get.

    If your query mapping is correct, this is the result of your query with the addition of the values of sum for the strand/down running.  Manually change the incorrect in the output bit numbers so that we can move on to find another solution.

    with gc_count like)

    Select

    Sum(current_high-current_low+1) on strand_high (g3e_fid seq order partition),

    Sum(current_high-current_low+1) more (partition of g3e_fid order of seq).

    strand_low (current_high-current_low),

    t.* from b$ gc_count t

    )

    Select

    a.g3e_fid, a.current_designation, a.current_low, a.current_high, a.strand_high, a.strand_low,

    b.g3e_fid, b.current_designation, b.current_low, b.current_high, b.strand_high, b.strand_low

    gc_count a, gc_count b

    where a.g3e_fid in (1008757155,1008757159,1009999655)

    and in b.g3e_fid (1008757155,1008757159,1009999655)

    and a.g3e_fid > b.g3e_fid

    and ((a.count_annotation = b.count_annotation)

    or (a.current_designation = b.current_designation

    and a.current_low b.current_low and b.current_high and a.current_high between b.current_low and b.current_high)

    order of b.seq

    /

    G3E_FID CURRENT_DESIGNATION CURRENT_LOW CURRENT_HIGH STRAND_HIGH STRAND_LOW G3E_FID CURRENT_DESIGNATION CURRENT_LOW CURRENT_HIGH STRAND_HIGH STRAND_LOW

    ---------- --------------------- ----------- ------------ ----------- ---------- ---------- --------------------- ----------- ------------ ----------- ----------

    GAGA GAGA 1008757159 1008757155 1 1 2 2 1 2 2 1

    1008757159 3 8 8 3 1008757155 3 8 8 3 F1DM F1DM

    1008757159 9 10 10 9 1008757155 9 10 10 9 F2 F2

    1008757159 11 14 14 11 1008757155 11 14 14 11 F1DM F1DM

    1009999655 17 18 6 5 1008757155 15 18 18 15 F2 F2

    1008757159 15 16 16 15 1008757155 15 18 18 15 F2 F2

    1009999655 21 24 4 1 1008757155 21 24 24 21 F2 F2

    7 selected lines.

    Elapsed time: 00:00:00.06

  • Nested loops in the XSLT handling

    Hello
    I want to manage nested loops for each within the transformation roadmap.
    I have two collections of source and a target collection.
    I have to search the value of key in source1 source2 and if the key is found, I map the value of the target, and if the key is not found, maybe I want to the key itself to target.

    This is the input samples and the results expected from the transformation roadmap. Please help turn in the required format.

    Entry
    ----------------------
    ------------------------
    < Source1Collection >
    < Group1 >
    < key > < / keys >
    i < value > < / value >
    < / Group1 >
    < Group2 >
    b < Key > < / key >
    II < value > < / value >
    < / Group2 >
    Group < 3 >
    < Key > c < / keys >
    III < value > < / value >
    < / Group 3 >
    < / Source1Collection >
    ---------------------------------------
    < Source2Collection >
    < Feild1 > z < / Feild1 >
    < Feild1 > x < / Feild1 >
    c < Feild1 > < / Feild1 >
    < Feild1 > v < / Feild1 >
    b < Feild1 > < / Feild1 >
    < / Source2Collection >
    ----------------------------------------

    Output
    --------------------------------------
    --------------------------------------
    < TargetCollection >
    < Field1 > one < / Feild1 >
    b < Field1 > < / Feild1 >
    III < Field1 > < / Feild1 >
    < / TargetCollection >

    is it possible that I can keep the position of the corresponding source2Key "?" This will help me to map the corresponding value of the sourceKey2 to the target.

    For something like that...

    
    1one
    2two
    3three
    
    

    You can use the following to get the value of a respective key...

    
    

    Thus, when $key = '2' the expression above will return "two"...

    I hope this helps...

    See you soon,.
    Vlad

  • Not the same State (<>) of nested loops

    Hi gurus and Experts.

    I need advice/suggestion on the query plan below. This plan is go for Nested Loops, am not able to force to go to the hash join or Merge Join with tips.
    Can someone help me please what is happening, and it is possible to escape from nested loops.
    I don't want to take the help of index for this scenario.

    D/B: Oracle 11 g 2,
    create table parent as
    with main as (select --+materialize 
    round(dbms_random.value(low=>1,high=>100)) SAMPLE_ID,dbms_random.string(opt=>'U',len=>10) SAMPLE_TEXT,rownum id from dual
    connect by level<=100000)
    select sample_id,rpad(sample_text,10,'*') padding,sample_text,id from main order by id
    create table child as
    with main as (select --+materialize 
    round(dbms_random.value(low=>1,high=>100)) SAMPLE_ID,dbms_random.string(opt=>'U',len=>10) SAMPLE_TEXT,rownum id from dual
    connect by level<=10000)
    select sample_id,rpad(sample_text,10,'*') padding,sample_text,id from main order by id
    select --+use_hash(p c)
    p.id from parent p,child c where p.id<>c.id
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 973,076  Bytes: 8,999,910,000  Cardinality: 999,990,000            
         3 NESTED LOOPS  Cost: 973,076  Bytes: 8,999,910,000  Cardinality: 999,990,000       
              1 TABLE ACCESS FULL TABLE APP.CHILD Cost: 12  Bytes: 40,000  Cardinality: 10,000  
              2 TABLE ACCESS FULL TABLE APP.PARENT Cost: 97  Bytes: 499,995  Cardinality: 99,999  

    902629 wrote:

    I need advice/suggestion on the query plan below. This plan is go for Nested Loops, am not able to force to go to the hash join or Merge Join with tips.

    You will not be able to use a hash join

    http://docs.Oracle.com/CD/E11882_01/server.112/e16638/optimops.htm#i36043

    >
    The optimizer uses hash join to join two tables if they are added by using an equijoin and if one of the following conditions are met:
    >

    You may be able to force a sort merge join, it does not mention if different will work, I don't see how it would be

    http://docs.Oracle.com/CD/E11882_01/server.112/e16638/optimops.htm#i49183

    >
    Sort merge joins are useful when the join condition between two tables is a condition of inequality such as <,> <=,>, or > =. Fusion type joints are more successful than joins loops nested for large sets of data. You cannot use hash joins unless there is a condition of equality.
    >

    I can't imagine this treatment an antijoin more efficiently than nested If loops.

  • Is the merge join Cartesian intensibe more CPU than nested loops?

    Hello
    just wonderning which access method is more intensive CPU, supposed to leave we got 2 the same rank sources and make joing via merge join Cartesian and then case is nested loop.
    I know that nl can be CPU due to the tight loop access, but what abour MJC?
    I can see bufferd sort but not sure is that cpu friendly?
    Concerning
    GregG

    The simplest answer I think is "it depends on the situation." Two of them could be disaster in different situations. Nested loops are suitable for a type of join and Cartesian for another.

  • When oracle uses a nested loop join full?

    Hello!

    Oracle database uses a complete nested loop join? I mean, imagine 2 tables without any index... is there a case where Oracle made a full scan of the inner table for each row in the outer table? I know it's the original algorithm of the nested loop join, but some databases prefer to do a temp table to autoindex the internal table and never does a full scan of the inner table...

    Thank you!!

    http://download.Oracle.com/docs/CD/B10501_01/server.920/a96533/optimops.htm#49548

    is 100% clear in its language. Simply click on it.
    A nested loop join involves the following steps:

    The optimizer determines the driving table and it designates as the outer table.
    The other table is referred to as the inner table.
    For each row in the outer table, Oracle access all rows from the inner table. The outer loop is for each row in the outer table, and the inner loop is for each line of the internal table. The outer loop appears before the inner loop in the execution plan, as follows:
    NESTED LOOPS
    outer_loop
    inner_loop

    Concerning
    Girish Sharma

  • Simple as possible"nested loop"XML (XPATH)?

    What is the best way to view the entries to an XML file with the following structure as a nested list (actually it must become a form where it is possible to control all entries).

    I can out of each level (see the code), but it seems not to be possible to nest loops for.

    Advice if it is directly possible with XPath or should I check the result of a loop to output in the other or it would even be better to make a query on the XML result?

    Thank you, excellent!

    I tried somwhere along this before, but it didn't work then. I have propably just forgot to bring the book of signs to the correct place or something ;-)

    But yes, your solution is exactly what I was looking for!

    Thank you

  • Partition pruning, nested loops

    Hello

    I'm having a problem with obtaining the size of partition in a query. I managed to dumb down the problem to the two tables and a minimum query (see below).

    Basically I have a partitioned table "Made each year" and a table of assistance 'Current year' that contain always 1 row. The sole purpose of this line is to say which is the year curent, it was the previous year and that next year will be. (In the real problem, there is no standard timeperiods, so we can't calculate just previous and next by adding/subtraction 1 as would be possible in this example).

    The following query is executed as I want.
    It runs a scan on current_year and then nested loop on the facts. And the size of the partition that was happening.
    select sum(decode(a.year_key, b.curr_year, some_measure)) as curr_year_measure
      from yearly_fact_t a
          ,current_year  b
     where a.year_key = b.curr_year;
    
    ------------------------------------------------------------------------------------------------------------
    | Id  | Operation                  | Name          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    ------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT           |               |     1 |    39 |     4   (0)| 00:00:01 |       |    |
    |   1 |  SORT AGGREGATE            |               |     1 |    39 |            |          |       |    |
    |   2 |   NESTED LOOPS             |               |     1 |    39 |     4   (0)| 00:00:01 |       |    |
    |   3 |    INDEX FAST FULL SCAN    | SYS_C00247890 |     1 |    13 |     2   (0)| 00:00:01 |       |    |
    |   4 |    PARTITION RANGE ITERATOR|               |     1 |    26 |     2   (0)| 00:00:01 |   KEY |   KEY |
    |*  5 |     TABLE ACCESS FULL      | YEARLY_FACT_T |     1 |    26 |     2   (0)| 00:00:01 |   KEY |   KEY |
    ------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - filter("A"."YEAR_KEY"="B"."CURR_YEAR")
    The following query is where I have my problem.
    The xplan base is the same, but for some reason any cbo abandoned and decide to analyze all the partitions, which was not highly scalable data on production :)
    I would have thought that the plan would be the same.
    select sum(decode(a.year_key, b.curr_year, some_measure)) as curr_year_measure
          ,sum(decode(a.year_key, b.prev_year, some_measure)) as prev_year_measure
      from yearly_fact_t a
          ,current_year  b
     where a.year_key = b.curr_year
        or a.year_key = b.prev_year;
    
    -------------------------------------------------------------------------------------------------------
    | Id  | Operation             | Name          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    -------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT      |               |     1 |    52 |    13   (0)| 00:00:01 |       |       |
    |   1 |  SORT AGGREGATE       |               |     1 |    52 |            |          |       |       |
    |   2 |   NESTED LOOPS        |               |     4 |   208 |    13   (0)| 00:00:01 |       |       |
    |   3 |    TABLE ACCESS FULL  | CURRENT_YEAR  |     1 |    26 |     4   (0)| 00:00:01 |       |       |
    |   4 |    PARTITION RANGE ALL|               |     4 |   104 |     9   (0)| 00:00:01 |     1 |     6 |
    |*  5 |     TABLE ACCESS FULL | YEARLY_FACT_T |     4 |   104 |     9   (0)| 00:00:01 |     1 |     6 |
    -------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - filter("A"."YEAR_KEY"="B"."CURR_YEAR" OR "A"."YEAR_KEY"="B"."PREV_YEAR")
    -- drop table yearly_fact_t purge;
    -- drop table current_year  purge;
    
    create table current_year(
       curr_year number(4) not null
      ,prev_year number(4) not null
      ,next_year number(4) not null
      ,primary key(curr_year)
      ,unique(prev_year)
      ,unique(next_year)
    );
    
    insert into current_year(curr_year, prev_year, next_year) values(2010, 2009, 2011);
    commit;
    
    create table yearly_fact_t(
       year_key     number(4) not null
      ,some_dim_key number    not null
      ,some_measure number    not null
    )
    partition by range(year_key)(
       partition p2007 values less than(2008)
      ,partition p2008 values less than(2009)
      ,partition p2009 values less than(2010)
      ,partition p2010 values less than(2011)
      ,partition p2011 values less than(2012)  
      ,partition pmax  values less than(maxvalue)
    );
    
    insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2007,1, 10);
    insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2008,1, 20);
    insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2009,1, 30);
    insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2010,1, 40);
    
    commit;
    What can I do to get the size of partition that you want to occur in the second query?
    Or better yet, what is it in my query that prevents it from happening?

    We do not have Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit.

    Best regards
    Ronnie

    I think that the decision of condition influenced gold optimizer. You can rewrite your query to use UNION ALL to see if it helps.

    select sum(decode(year_key, curr_year, some_measure)) as curr_year_measure
          ,sum(decode(year_key, prev_year, some_measure)) as prev_year_measure
    from (select a.year_key, b.curr_year, some_measure
      from yearly_fact_t a
          ,current_year  b
     where a.year_key = b.curr_year
    UNION ALL
    select a.year_key, b.curr_year, some_measure
      from yearly_fact_t a
          ,current_year  b
     where a.year_key = b.prev_year);
     
    

    Published by: user503699 on February 17, 2010 14:59

  • How to quit the nested loop

    I have a nested loop

    loop1 start
    ...
    loop2 start
    ...
    end loop2
    ...
    end loop1

    I want to know how can I come out the two loops of the inner loop.

    Hello
    Out of the inner loop in the use of nested loops labels

    SQL> BEGIN
      2          <>
      3            FOR i IN 1..2 LOOP
      4                 <>
      5                 FOR j IN 1..4 LOOP
      6                      DBMS_OUTPUT.PUT_LINE('I am in Inner Loop');
      7                 END LOOP inner;
      8       DBMS_OUTPUT.PUT_LINE('I am in outer Loop');
      9            END LOOP outer;
     10   END;
     11   /
    I am in Inner Loop
    I am in Inner Loop
    I am in Inner Loop
    I am in Inner Loop
    I am in outer Loop
    I am in Inner Loop
    I am in Inner Loop
    I am in Inner Loop
    I am in Inner Loop
    I am in outer Loop
    
    PL/SQL procedure successfully completed.
    
    SQL> BEGIN
      2          <>
      3            FOR i IN 1..2 LOOP
      4                 <>
      5                 FOR j IN 1..4 LOOP
      6                      DBMS_OUTPUT.PUT_LINE('I am in Inner Loop');
      7       exit inner;
      8                 END LOOP inner;
      9       DBMS_OUTPUT.PUT_LINE('I am in outer Loop');
     10            END LOOP outer;
     11   END;
     12   /
    I am in Inner Loop
    I am in outer Loop
    I am in Inner Loop
    I am in outer Loop
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> BEGIN
      2          <>
      3            FOR i IN 1..2 LOOP
      4                 <>
      5                 FOR j IN 1..4 LOOP
      6                      DBMS_OUTPUT.PUT_LINE('I am in Inner Loop');
      7       exit outer;
      8                 END LOOP inner;
      9       DBMS_OUTPUT.PUT_LINE('I am in outer Loop');
     10            END LOOP outer;
     11   END;
     12   /
    I am in Inner Loop
    
    PL/SQL procedure successfully completed.
    

    Twinkle

  • nested loops for speed optimization

    Hello. I need help to optimize for speed (in LabVIEW) code (matlab) following:

    -----------------------------------

    a = rand(1024, 200);
    b = rand(1024, 512);
    c = Zeros (200,512);
    ICT
    for i = 1: 200
    j = 1:512
    c (i, j) = (Sum ((:,i).*b(:,j))) a ABS;
    end
    end
    Table of contents
    end

    -------------------------------------------------------------

    Basically I have two 2d tables, a and b, one with 200 columns and rows of 1024, other columns a 512 and 1024 lines. What I have to do is multiply (dot product) each column a each column of b, the sum and take the absolute value of the result. The output, c, will be an array of 2d of size 200 x 512. Is it possible to do without the help of 2 loops of nesting? The two paintings 2d, a and b\, are produced by my material.

    What is the best strategy to get the maximum speed? I have a powerful enough processor.

    Thank you very much?

    So I looked at this problem, said «seems familiar, but different...» ».  Did a little math, encoded at top and improved the speed by a factor of 100 (with absolutely no parallelism).  How about apples?

    If we let A and B tables 1024 x 512 and 1024 x 200 and turn them into matrices, the problem is (mathematically) the absolute value of the transposed from A times B, where "the times" are the multiplication of matrices.  I "guessed" that NEITHER would have included the Multiplication of matrices in his bag of tricks and maybe optimized, so I coded it upward, adding the calendar.

    Using the first double Lynn - to multiply, sum, formulation of abs and a 'do it as a matrix' on my machine, the Array 1004 msec, the matrix method took 10 msec, as well as the results differ by less than one part in 1 million (I generated at random (0, 1) floats, and made the comparison by subtracting the two tables and checking that the absolute all the differences were less than 1E-6).

    Bob Schor

  • multiple inputs and nested loop problem

    Hello world

    I'm using Labview 2009.

    I want to change the value of a variable by using the wheel or keyboard.

    So I downloaded a button and the screws of the keyboard that suits my needs of multi-rotation forum.

    These two screws are running inside a WHILE loop. Because I would be constantly updating the variable I will run my main screw that houses these two screws also looped a WHILE.

    Problem is that while loop within a while loop I couldn't run my main VI because of this problem.

    I tried in 2ways

    1 including them as an auxiliary in my main VI but as the two screws screw contains a few other variables inside of the inside while loop that LabVIEW displays error as auxiliary screws will not work

    2. I also tried to copy paste the two screws as it is in my main screw but could end up only in a lot of errors.

    How to deal with this problem of nested while loops?

    Please guide me.

    Kind regards

    Maury

    You make a mistake of data flow. The outer loop can turn only if all of the code that he has completed. The structure of the event cannot complete because inside while loop has not finished, and if inside so that the loop ends, the loop cannot turn because the structure of the event stalls. You can only go to the next iteration after all both have completed, from the mess.

    All you need to do to incorporate ALL the code inside the structure of the event. Attached, it's a simple project (LV 9.0), modify as necessary.

    See if it makes sense for you. (there are a few minor bugs probably)

Maybe you are looking for