SQL model fibonacci

Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE Production 11.2.0.3.0

AMT for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 - Production

Hi there thank you in advance. I learn the sql model and try this fibonacci:

SELECT x, s

OF THE DOUBLE

MODEL OF RETURN ALL ROWS

DIMENSION (1 x)

MEASURES (0 s AS)

IGNORE THE NAV

RULES

(s [1] = 0,)

s [2] = 1;

s [BETWEEN 3 AND 5 x] = s [x = cv (x)-1] + s [x = cv (x) - 2])

but it stops after printing 2 rows:

10
21

My question is: why the third rule s [BETWEEN 3 AND 5 x] = s [x = cv (x)-1] + s [x = cv (x) - 2]) does not work?

It is positional and symbolic references.

Creation of new cells only works for positional references.

s [x > 3] is a reference to symboic that x is the symbol of the dimension.

s [3] is a positional reference.

References in the loops FOR are considered to be positional referecenes, even if they are formulated using symbols.

1 x SELECT, s

2 FROM TWO

MODEL 3 RETURNS ALL ROWS

4 DIMENSION BY (1 x)

5 MEASURES (0 s AS)

6 SKIP NAV

7 RULES

8        (s [1] = 0,

9 s [2] = 1,

10 s upsert [3] = 1

11)

12 * order by s

X S

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

1 0
2 1
3 1

Tags: Database

Similar Questions

  • Change SQL model #4 and default SQL DDL #5

    Hello

    on the FSCM 9.1, 52.0 on Win 2008 Server tools;

    to force AE statistics we should do:

    6 change SQL #4 and #5 DDL SQL model by default for the Oracle platform to allow through option when updating

    Recommended in:

    RED_PAPER_ - _PeopleSoft_Enterprise_Performance_on_Oracle_11g_Database.pdf

    Can you be kind and tell us how to find (SQL #4)?

    Thank you.

    DDL models are under

    PeopleTools > utilities > Administration > DDL default model

    Select the Oracle platform in the search, and you should get a scroll with 5 rows. Lines 4 and 5 must begin with DBMS_STATS. GATHER_TABLE_STATS

    You can also consider to download the tool from Oracle's Support:

    pscbo_stats - improve statistics in RDBMS to Oracle for PeopleSoft Enterprise [1322888.1 ID]

    See the statistics of PeopleSoft database update for more information.

    Kind regards

    Bob

  • Free version of SQL Modeller?

    Hello

    If I got it to open world, then SQL Modeler will be a free version. He knows when he is expected to be released?

    Tamas

    If I read this right, there is only one version, and if you have a license for Oracle - now included...

    Re: Data model for free

    Published by: SQL - something on Sep 25, 2010 20:30

  • Corresponding SQL model

    Hello

    I have a data set that is similar to the following

    00-1111-2222
    01-2000
    ABCDEFG
    A bcde
    04-3456
    08-2001

    I want to retrieve only the records that match the following model: #-YYYY where # is a number and YYYY is a year
    So in this case I just want back 2000-01 to 08-2001. I tried to use regexp_like but in vain (operator not valid error)
    Is there a simple way to do this without the help of functions or PLSQL just in SQL? It doesn't have to be with regexp_like, just any SQL tool.

    Thanks in advance, any help is appreciated

    Hello

    dbarcell wrote:
    It would be prudent to use any higher than 1995 year

    I would not return 04-3456 to this query

    3456 is a 1995 graduate. Why you not want it?

    The following selects rows where str fits the model and the year is 1995 and 2100 betwwen. You can easily change it to any other 4-digit years:

    WHERE     REGEXP_LIKE ( str
                  , '^\d{2}-\d{4}$'
                  )
    AND     SUBSTR (str, 4, 4)     BETWEEN     '1995'
                                    AND     '2100' 
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

    Published by: Frank Kulash, August 9, 2011 17:58

    Here's another way; a little faster and works in versions prior to version Oracle 10:

    WHERE     TRANSLATE ( str
                , '012345678'
                , '999999999'
                )          = '99-9999'
    AND     SUBSTR (str, 4, 4)     BETWEEN     '1995'
                                    AND     '2100' 
    

    If the first two digits must be '01' to '12', then add

    AND     SUBSTR (str, 1, 2)     BETWEEN     '01'
                                    AND     '12'
    

    for each version.

  • Use of domains in SQL data Developer MODEL

    Hello

    I'm trying to understand how to use areas of Oracle SQL Developer Data Modeler. We use version 3.1.3.  before I used Toad Modeler where the areas are just a part of your main design.

    Modeler data Oracle has a different concept.

    Suppose that I am working on 2 models: DesignA and DesignB which include relational models.

    DesignA and design B must use areas, but the list of areas in A design is very different from design B.

    Default domain file is located on drive c:, where SqlModeler is installed. It is of course unacceptable, so I need to change the default system Type directory in preferences.

    And of course, I want to have directories different area's of DESIGN and DESIGN B.

    So when I opened design has then I changed the default directory Type system we'll tell x:\AAA.   Then I close A design open design B and change the default directory of x:\BBB system Type

    I checked records AAA and BBB and they have required XML files here: defaultdomains.xml, defaultRFDBSSites and so on...

    Now the questions:

    can I rename defaultdomains.xls to something like AAAdomains.xls?  Domain administration can change any file with any name field, but how do I associate some file field with my design?  My wish, when I opened my design, and then the domain file will be automatically opened.  Is this possible?

    If I open 2 designs in Sql Modeler and switch between corresponding designs and domain files then need to be changed automatically as well.  Currently, I shouldn't forget to change the default system Type directory each time when I switch templates.  It is the only way to deal with?

    Thank you

    Vitaliy

    Vitaliy salvation,

    to see which domain files are used, the simplest is to go into the administration of the domain,

    Add new domain and then check the drop-down list for the property 'areas file' box - used files appears.

    Keep in mind that in defaultdomains.xml areas are still part of the domain that is used in the design. If this file must be empty (containing only 'unknown' domain) If you want to work

    with areas of level design.

    Philippe

  • Performance-to-many problem (using the model of the FAQ)

    After reading "HOW TO: post a request for tuning SQL - model showing statement" I gathered:

    I have included some general information at the bottom of the post

    The following SQL statement has been identified as a bad performance. It takes ~ 160 seconds to run, but similar (indicated below first statement) SQL statements run in ~ 1 second.

    SQL taking 160 seconds:
    SELECT
    a.*
    FROM
    table_a a
    INNER JOIN table_a_b ab ON a.id = ab.media_fk
    WHERE
    ab.channel_fk IN (7, 1);
    SQL in ~ 1 second or less
    ...
    ab.channel_fk IN (7);
    Or:
    ...
    ab.channel_fk IN (6, 9, 170, 89);
    The purpose of the SQL is to return lines from table_a associated table_b (not in SQL) through the junction table table_a_b.

    The version of the database is 10.2.0.4.0

    These are the parameters relevant for the optimizer:
    show parameter optimizer;
    
    NAME                                               TYPE        VALUE
    -------------------------------------------------- ----------- -----------------------------------------
    optimizer_dynamic_sampling                         integer     2
    optimizer_features_enable                          string      10.2.0.4
    optimizer_index_caching                            integer     0
    optimizer_index_cost_adj                           integer     100
    optimizer_mode                                     string      ALL_ROWS
    optimizer_secure_view_merging                      boolean     TRUE
    
    show parameter db_file_multi;
    
    NAME                                               TYPE        VALUE
    -------------------------------------------------- ----------- -----------------------------------------
    db_file_multiblock_read_count                      integer     16
    
    show parameter db_block_size;
    
    NAME                                               TYPE        VALUE
    -------------------------------------------------- ----------- -----------------------------------------
    db_file_multiblock_read_count                      integer     16
    
    select sname, pname, pval1, pval2 from sys.aux_stats$;
    
    SNAME                          PNAME                          PVAL1                  PVAL2
    ------------------------------ ------------------------------ ---------------------- -------------------
    SYSSTATS_INFO                  STATUS                                                COMPLETED
    SYSSTATS_INFO                  DSTART                                                07-18-2006 23:19
    SYSSTATS_INFO                  DSTOP                                                 07-25-2006 23:19
    SYSSTATS_INFO                  FLAGS                          0
    SYSSTATS_MAIN                  SREADTIM                       5.918
    SYSSTATS_MAIN                  MREADTIM                       7.889
    SYSSTATS_MAIN                  CPUSPEED                       1383
    SYSSTATS_MAIN                  MBRC                           8
    SYSSTATS_MAIN                  MAXTHR                         1457152
    SYSSTATS_MAIN                  SLAVETHR                       -1
    Here is the output of the EXPLAIN PLAN of:
    PLAN_TABLE_OUTPUT
    Plan hash value: 3781163428
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation             | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT      |                    |  1352K|   771M|       | 60042   (3)| 00:05:56 |
    |*  1 |  HASH JOIN            |                    |  1352K|   771M|    27M| 60042   (3)| 00:05:56 |
    |*  2 |   INDEX FAST FULL SCAN| SYS_IOT_TOP_316310 |  1352K|    11M|       |  1816   (4)| 00:00:11 |
    |   3 |   TABLE ACCESS FULL   | TABLE_A            |  2190K|  1230M|       | 32357   (4)| 00:03:12 |
    ----------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access(""AB"".""MEDIA_FK""=""A"".""ID"")
       2 - filter(""AB"".""CHANNEL_FK""=1 OR ""AB"".""CHANNEL_FK""=7)
    
    Note
    -----
       - 'PLAN_TABLE' is old version
    For reference, the EXPLAIN PLAN when using
    ...
    ab.channel_fk IN (6, 9, 170, 89);
    that runs in ~ 1 second is:
    PLAN_TABLE_OUTPUT
    Plan hash value: 794334170
    
    ----------------------------------------------------------------------------------------
    | Id  | Operation          | Name      | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |           |   143K|    81M|       | 58982   (3)| 00:05:50 |
    |*  1 |  HASH JOIN         |           |   143K|    81M|  2952K| 58982   (3)| 00:05:50 |
    |   2 |   INLIST ITERATOR  |           |       |       |       |            |          |
    |*  3 |    INDEX RANGE SCAN| C_M_INDEX |   143K|  1262K|       |  1264   (1)| 00:00:08 |
    |   4 |   TABLE ACCESS FULL| TABLE_A   |  2190K|  1230M|       | 32357   (4)| 00:03:12 |
    ----------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access(""AB"".""MEDIA_FK""=""A"".""ID"")
       3 - access(""AB"".""CHANNEL_FK""=6 OR ""AB"".""CHANNEL_FK""=9 OR
                  ""AB"".""CHANNEL_FK""=89 OR ""AB"".""CHANNEL_FK""=170)
    
    Note
    -----
       - 'PLAN_TABLE' is old version
    Here is the output of SQL * Plus AUTOTRACE, including CALENDAR information:
    SQL> set autotrace traceonly arraysize 100;
    SQL> SELECT
      2  a.*
      3  FROM
      4  table_a a
      5  INNER JOIN table_a_b ab ON a.id = ab.media_fk
      6  WHERE
      7  ab.channel_fk IN (7, 1);
    
    1336148 rows selected.
    
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3781163428
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation             | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT      |                    |  1352K|   771M|       | 60042   (3)| 00:05:56 |
    |*  1 |  HASH JOIN            |                    |  1352K|   771M|    27M| 60042   (3)| 00:05:56 |
    |*  2 |   INDEX FAST FULL SCAN| SYS_IOT_TOP_316310 |  1352K|    11M|       |  1816   (4)| 00:00:11 |
    |   3 |   TABLE ACCESS FULL   | TABLE_A            |  2190K|  1230M|       | 32357   (4)| 00:03:12 |
    ----------------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access("AB"."MEDIA_FK"="A"."ID")
       2 - filter("AB"."CHANNEL_FK"=1 OR "AB"."CHANNEL_FK"=7)
    
    Note
    -----
       - 'PLAN_TABLE' is old version
    
    
    Statistics
    ----------------------------------------------------------
          10586  recursive calls
              0  db block gets
         200457  consistent gets
         408343  physical reads
              0  redo size
      498740848  bytes sent via SQL*Net to client
         147371  bytes received via SQL*Net from client
          13363  SQL*Net roundtrips to/from client
             49  sorts (memory)
              0  sorts (disk)
        1336148  rows processed
    The TKPROF output for that statement looks like the following:
    TKPROF: Release 10.2.0.4.0 - Production on Mon Oct 1 12:23:21 2012
    
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    
    Trace file: ..._ora_4896.trc
    Sort options: default
    
    ********************************************************************************
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    ********************************************************************************
    
    ALTER SYSTEM SET TIMED_STATISTICS = TRUE
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.03          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2      0.00       0.03          0          0          0           0
    
    Misses in library cache during parse: 0
    Parsing user id: 21
    ********************************************************************************
    
    SELECT
    a.*
    FROM
    table_a a
    INNER JOIN table_a_b ab ON a.id = ab.media_fk
    WHERE
    ab.channel_fk IN (7, 1)
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     27.23     163.57     179906     198394          0          16
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     27.25     163.58     179906     198394          0          16
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 21
    
    
    
    ********************************************************************************
    
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        2      0.01       0.00          0          0          0           0
    Execute      2      0.00       0.03          0          0          0           0
    Fetch        2     27.23     163.57     179906     198394          0          16
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        6     27.25     163.62     179906     198394          0          16
    
    Misses in library cache during parse: 1
    
    
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        0      0.00       0.00          0          0          0           0
    
    Misses in library cache during parse: 0
    
        2  user  SQL statements in session.
        0  internal SQL statements in session.
        2  SQL statements in session.
    ********************************************************************************
    Trace file: ..._ora_4896.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    
           1  session in tracefile.
           2  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           2  SQL statements in trace file.
           2  unique SQL statements in trace file.
          46  lines in trace file.
         187  elapsed seconds in trace file.
    DBMS_XPLAN. Output DISPLAY_CURSOR:
    select * from table(dbms_xplan.display_cursor('474frsqbc1n4d', null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    SQL_ID  474frsqbc1n4d, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */ c.* FROM table_a c INNER JOIN table_a_b ab ON c.id = ab.media_fk WHERE ab.channel_fk IN (7, 1)
    
    Plan hash value: 3781163428
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation             | Name               | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |  OMem |  1Mem | Used-Mem |
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    |*  1 |  HASH JOIN            |                    |      1 |   1352K|   1050 |00:00:40.93 |     198K|    182K|    209K|    29M|  5266K| 3320K (1)|
    |*  2 |   INDEX FAST FULL SCAN| SYS_IOT_TOP_316310 |      1 |   1352K|   1336K|00:00:01.34 |   10874 |      0 |      0 |       |       |          |
    |   3 |   TABLE ACCESS FULL   | TABLE_A            |      1 |   2190K|   2267K|00:02:45.56 |     187K|    182K|      0 |       |       |          |
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access(""AB"".""MEDIA_FK""=""C"".""ID"")
       2 - filter((""AB"".""CHANNEL_FK""=1 OR ""AB"".""CHANNEL_FK""=7))
    Thank you for reading I'm waiting for suggestions to improve the performance of this statement.

    -----

    H3. Backgroud

    There are many years my company made decided to maintain many-to-many relationships in our database using pipe delimited fields. An example of field value:
    '|ABC|XYZ|VTR|DVD|'
    Each delimited value refers to a unique "short" code TABLE_B (there is also a real digital foreign key to TABLE_B, which is what I use in the junction table). We are regularly using these columns with the next SQL style:
    ...
    WHERE
    INSTR(pipedcolumn, '|ABC|') > 0
    OR INSTR(pipedcolumn, '|XYZ|' > 0
    ...
    Appropriate indexes have been created over the years to make this process as soon a possible.

    We now have an opportunity to correct some of these errors of design and implementation of junction tables to replace the current field. Before that, we have decided to take a copy of a database to a client with the largest set of records and test. I created a new junction table:
    TABLE_A_B DDL:
    
        CREATE TABLE TABLE_A_B (
            media_fk NUMBER,
            channel_fk NUMBER,
            PRIMARY KEY (media_fk, channel_fk),
            FOREIGN KEY (media_fk) REFERENCES TABLE_A (ID),
            FOREIGN KEY (channel_fk) REFERENCES TABLE_B (ID)
        ) ORGANIZATION INDEX COMPRESS;
    
        CREATE INDEX C_M_INDEX ON TABLE_A_B (channel_fk, media_fk) COMPRESS;
    And the analysis on a pipe delimited field, populated by this new table.

    I then compared the performance of the following SQL:
    SELECT
    a.*
    FROM
    table_a a
    INNER JOIN table_a_b ab ON a.id = ab.media_fk
    WHERE
    ab.channel_fk IN (x, y, n); -- Can be Many Minutes
    
    --vs.
    
    SELECT
    a.*
    FROM
    table_a a
    WHERE
    INSTR(OWNERS,'|x|')    >0
    OR INSTR(OWNERS,'|y|')    >0
    OR INSTR(OWNERS,'|n|')    >0; -- About 1 second seemingly regardless
    When x, y, n are values that occur less frequently in the TABLE_A_B.CHANNEL_FK performance are comparable. However once the frequency of x, y, n increases, performance suffers. Here is a summary of the data CHANNEL_FK in TABLE_A_B:
    --SQL For Summary Data
    SELECT channel_fk, count(channel_fk) FROM table_a_b GROUP BY channel_fk ORDER BY COUNT(channel_fk) DESC;
    
    CHANNEL_FK             COUNT(CHANNEL_FK)
    ---------------------- ----------------------
    7                      780741
    1                      555407
    2                      422493
    3                      189493
    169                    144663
    9                      79457
    6                      53051
    171                    28401
    170                    19857
    49                     12603
    ...
    I noticed that whenever I use any combination of values that occur over approximately 800 000 times (i.e. IN (7, 1) = 780741 + 555407 = 1336148) then I get performance problems.

    I find it very difficult to accept that the old pipe delimited fields are a better solution (without taking into account any other than this search criterion!).

    Thank you for reading this far. I really look forward to suggestions on how to improve the performance of this statement.

    Published by: user1950227 on October 1, 2012 12:06
    Table of link renamed in DDL.

    davebcast wrote:

    The following SQL statement has been identified as a bad performance. It takes ~ 160 seconds to run, but similar (indicated below first statement) SQL statements run in ~ 1 second.

    Keep in mind that the enforcement timeframe has elapsed is a poor metric to use for benchmarking of SQL. The reason is that the same workload does not mean that the same elapsed execution time.

    The workload for example shows a block of 1000 readings. There will be a difference marked by this workload reading data of the slow physical disks, or making this workload by reading data from memory in memory cache. And if it happens to be in memory or on disk is a kind of "random" thing (depends on many environment and factors of execution).

    Thus, rather than measure the elapsed time and use it to compare, rather compare actual workloads. A workload of 500 block reading is faster and better than a block of 1000 DSL - despite the fact that a point of elapsed time can show the 500 read being slow (e/s physical) block a block of 1000 to read (e/s logic).

  • Formula of number first in PL/SQL

    Hi friends,

    Oracle 11.2.0.1
    Windows XP Prof

    Two questions, but almost of the same nature:

    1. is there a formula by which we can get the total number of numbers first to a number given; I mean suppose I said 10, it means he must return 3; that is, there are total 3 prime number between 1 and 10.

    Here I use a function that will tell me that a number is first or not, and I will make a loop to the given number. But this isn't really a formula, that kind of calculation. I'm looking for a formula fixed matehematical if there is or not. If exists, then how this PL/SQL block looks.

    2 suppose I want to get 50 numbers first (starting from 1), then what will be the 50th prime number, I mean up to highest number my calculation will be expanded.

    If possible, it should also be based on a fixed formula.

    Not actually a requirement for business, but my nephew (pupil of class 9) asked me these questions. I said to him, or I am a student of math or knowledgeable in PL/SQL.

    I asked him why you are looking for these formulas. He simply said the issues raised in my mind and curious to know that this is a fixed formula in math exists or not. I said to him: "did you ask your math teacher? He said "Yes, Mr. president told me, that there is no such a fixed mathematical formula, because there is no fixed gap in their range, what said you?"

    I thought: Let me write here.

    Concerning
    Girish Sharma

    Using SQL & MODEL. Not the fastest solution, but calculates the first 1000 prime numbers in 5 seconds:

    CNT VARIABLE NUMBER

    EXEC: cnt: = 1000;

    First SELECT

    OF the double

    CONNECT BY LEVEL<>

    MODEL

    DIMENSION)

    level i

    )

    MEASURES)

    level begins,

    probe 0,

    is_prime 0,.

    2 prime_cnt

    )

    RULES ITERATE (1e9) UNTIL(prime_cnt[1] >=:cnt))

    (

    the probe [any] = 2 * iteration_number + 3,

    is_prime [1] = box

    When min (mod (probe, award-winning)) [I have between 2 and probe [1] / 2] = 0

    then 0

    1 other

    end,

    prime_cnt [1] = prime_cnt [1] + is_prime [1].

    probe [1] = box

    When is_prime [1] = 0

    then 1

    probe on the other [1]

    end,

    first [probe [1]] = probe [1]

    )

    /

    FIRST
    ----------
    1
    2
    3
    5
    7
    11
    13
    17
    19
    23
    29

    FIRST
    ----------
    31
    37
    41
    43
    47
    53
    59
    61
    67
    71
    73

    FIRST
    ----------
    79
    83
    89
    97
    101
    103
    107
    109
    113
    127
    131

    FIRST
    ----------
    137
    139
    149
    151
    157
    163
    167
    173
    179
    181
    191

    FIRST
    ----------
    193
    197
    199
    211
    223
    227
    229
    233
    239
    241
    251

    FIRST
    ----------
    257
    263
    269
    271
    277
    281
    283
    293
    307
    311
    313

    FIRST
    ----------
    317
    331
    337
    347
    349
    353
    359
    367
    373
    379
    383

    FIRST
    ----------
    389
    397
    401
    409
    419
    421
    431
    433
    439
    443
    449

    FIRST
    ----------
    457
    461
    463
    467
    479
    487
    491
    499
    503
    509
    521

    FIRST
    ----------
    523
    541
    547
    557
    563
    569
    571
    577
    587
    593
    599

    FIRST
    ----------
    601
    607
    613
    617
    619
    631
    641
    643
    647
    653
    659

    FIRST
    ----------
    661
    673
    677
    683
    691
    701
    709
    719
    727
    733
    739

    FIRST
    ----------
    743
    751
    757
    761
    769
    773
    787
    797
    809
    811
    821

    FIRST
    ----------
    823
    827
    829
    839
    853
    857
    859
    863
    877
    881
    883

    FIRST
    ----------
    887
    907
    911
    919
    929
    937
    941
    947
    953
    967
    971

    FIRST
    ----------
    977
    983
    991
    997
    1009
    1013
    1019
    1021
    1031
    1033
    1039

    FIRST
    ----------
    1049
    1051
    1061
    1063
    1069
    1087
    1091
    1093
    1097
    1103
    1109

    FIRST
    ----------
    1117
    1123
    1129
    1151
    1153
    1163
    1171
    1181
    1187
    1193
    1201

    FIRST
    ----------
    1213
    1217
    1223
    1229
    1231
    1237
    1249
    1259
    1277
    1279
    1283

    FIRST
    ----------
    1289
    1291
    1297
    1301
    1303
    1307
    1319
    1321
    1327
    1361
    1367

    FIRST
    ----------
    1373
    1381
    1399
    1409
    1423
    1427
    1429
    1433
    1439
    1447
    1451

    FIRST
    ----------
    1453
    1459
    1471
    1481
    1483
    1487
    1489
    1493
    1499
    1511
    1523

    FIRST
    ----------
    1531
    1543
    1549
    1553
    1559
    1567
    1571
    1579
    1583
    1597
    1601

    FIRST
    ----------
    1607
    1609
    1613
    1619
    1621
    1627
    1637
    1657
    1663
    1667
    1669

    FIRST
    ----------
    1693
    1697
    1699
    1709
    1721
    1723
    1733
    1741
    1747
    1753
    1759

    FIRST
    ----------
    1777
    1783
    1787
    1789
    1801
    1811
    1823
    1831
    1847
    1861
    1867

    FIRST
    ----------
    1871
    1873
    1877
    1879
    1889
    1901
    1907
    1913
    1931
    1933
    1949

    FIRST
    ----------
    1951
    1973
    1979
    1987
    1993
    1997
    1999
    2003
    2011
    2017
    2027

    FIRST
    ----------
    2029
    2039
    2053
    2063
    2069
    2081
    2083
    2087
    2089
    2099
    2111

    FIRST
    ----------
    2113
    2129
    2131
    2137
    2141
    2143
    2153
    2161
    2179
    2203
    2207

    FIRST
    ----------
    2213
    2221
    2237
    2239
    2243
    2251
    2267
    2269
    2273
    2281
    2287

    FIRST
    ----------
    2293
    2297
    2309
    2311
    2333
    2339
    2341
    2347
    2351
    2357
    2371

    FIRST
    ----------
    2377
    2381
    2383
    2389
    2393
    2399
    2411
    2417
    2423
    2437
    2441

    FIRST
    ----------
    2447
    2459
    2467
    2473
    2477
    2503
    2521
    2531
    2539
    2543
    2549

    FIRST
    ----------
    2551
    2557
    2579
    2591
    2593
    2609
    2617
    2621
    2633
    2647
    2657

    FIRST
    ----------
    2659
    2663
    2671
    2677
    2683
    2687
    2689
    2693
    2699
    2707
    2711

    FIRST
    ----------
    2713
    2719
    2729
    2731
    2741
    2749
    2753
    2767
    2777
    2789
    2791

    FIRST
    ----------
    2797
    2801
    2803
    2819
    2833
    2837
    2843
    No. 2851
    2857
    2861
    2879

    FIRST
    ----------
    2887
    2897
    2903
    2909
    2917
    2927
    2939
    2953
    2957
    2963
    2969

    FIRST
    ----------
    2971
    2999
    3001
    3011
    3019
    3023
    3037
    3041
    3049
    3061
    3067

    FIRST
    ----------
    3079
    3083
    3089
    3109
    3119
    3121
    3137
    3163
    3167
    3169
    3181

    FIRST
    ----------
    3187
    3191
    3203
    3209
    3217
    3221
    3229
    3251
    3253
    3257
    3259

    FIRST
    ----------
    3271
    3299
    3301
    3307
    3313
    3319
    3323
    3329
    3331
    3343
    3347

    FIRST
    ----------
    3359
    3361
    3371
    3373
    3389
    3391
    3407
    3413
    3433
    3449
    3457

    FIRST
    ----------
    3461
    3463
    3467
    3469
    3491
    3499
    3511
    3517
    3527
    3529
    3533

    FIRST
    ----------
    3539
    3541
    3547
    3557
    3559
    3571
    3581
    3583
    3593
    3607
    3613

    FIRST
    ----------
    3617
    3623
    3631
    3637
    3643
    3659
    3671
    3673
    3677
    3691
    3697

    FIRST
    ----------
    3701
    3709
    3719
    3727
    3733
    3739
    3761
    3767
    3769
    3779
    3793

    FIRST
    ----------
    3797
    3803
    3821
    3823
    3833
    3847
    3851
    3853
    3863
    3877
    3881

    FIRST
    ----------
    3889
    3907
    3911
    3917
    3919
    3923
    3929
    3931
    3943
    3947
    3967

    FIRST
    ----------
    3989
    4001
    4003
    4007
    4013
    4019
    4021
    4027
    4049
    4051
    4057

    FIRST
    ----------
    4073
    4079
    4091
    4093
    4099
    4111
    4127
    4129
    4133
    4139
    4153

    FIRST
    ----------
    4157
    4159
    4177
    4201
    4211
    4217
    4219
    4229
    4231
    4241
    4243

    FIRST
    ----------
    4253
    4259
    4261
    4271
    4273
    4283
    4289
    4297
    4327
    4337
    4339

    FIRST
    ----------
    4349
    4357
    4363
    4373
    4391
    4397
    4409
    4421
    4423
    4441
    4447

    FIRST
    ----------
    4451
    4457
    4463
    4481
    4483
    4493
    4507
    4513
    4517
    4519
    4523

    FIRST
    ----------
    4547
    4549
    4561
    4567
    4583
    4591
    4597
    4603
    4621
    4637
    4639

    FIRST
    ----------
    4643
    4649
    4651
    4657
    4663
    4673
    4679
    4691
    4703
    4721
    4723

    FIRST
    ----------
    4729
    4733
    4751
    4759
    4783
    4787
    4789
    4793
    4799
    4801
    4813

    FIRST
    ----------
    4817
    4831
    4861
    4871
    4877
    4889
    4903
    4909
    4919
    4931
    4933

    FIRST
    ----------
    4937
    4943
    4951
    4957
    4967
    4969
    4973
    4987
    4993
    4999
    5003

    FIRST
    ----------
    5009
    5011
    5021
    5023
    5039
    5051
    5059
    5077
    5081
    5087
    5099

    FIRST
    ----------
    5101
    5107
    5113
    5119
    5147
    5153
    5167
    5171
    5179
    5189
    5197

    FIRST
    ----------
    5209
    5227
    5231
    5233
    5237
    5261
    5273
    5279
    5281
    5297
    5303

    FIRST
    ----------
    5309
    5323
    5333
    5347
    5351
    5381
    5387
    5393
    5399
    5407
    5413

    FIRST
    ----------
    5417
    5419
    5431
    5437
    5441
    5443
    5449
    5471
    5477
    5479
    5483

    FIRST
    ----------
    5501
    5503
    5507
    5519
    5521
    5527
    5531
    5557
    5563
    5569
    5573

    FIRST
    ----------
    5581
    5591
    5623
    5639
    5641
    5647
    5651
    5653
    5657
    5659
    5669

    FIRST
    ----------
    5683
    5689
    5693
    5701
    5711
    5717
    5737
    5741
    5743
    5749
    5779

    FIRST
    ----------
    5783
    5791
    5801
    5807
    5813
    5821
    5827
    5839
    5843
    5849
    5851

    FIRST
    ----------
    5857
    5861
    5867
    5869
    5879
    5881
    5897
    5903
    5923
    5927
    5939

    FIRST
    ----------
    5953
    5981
    5987
    6007
    6011
    6029
    6037
    6043
    6047
    6053
    6067

    FIRST
    ----------
    6073
    6079
    6089
    6091
    6101
    6113
    6121
    6131
    6133
    6143
    6151

    FIRST
    ----------
    6163
    6173
    6197
    6199
    6203
    6211
    6217
    6221
    6229
    6247
    6257

    FIRST
    ----------
    6263
    6269
    6271
    6277
    6287
    6299
    6301
    6311
    6317
    6323
    6329

    FIRST
    ----------
    6337
    6343
    6353
    6359
    6361
    6367
    6373
    6379
    6389
    6397
    6421

    FIRST
    ----------
    6427
    6449
    6451
    6469
    6473
    6481
    6491
    6521
    6529
    6547
    6551

    FIRST
    ----------
    6553
    6563
    6569
    6571
    6577
    6581
    6599
    6607
    6619
    6637
    6653

    FIRST
    ----------
    6659
    6661
    6673
    6679
    6689
    6691
    6701
    6703
    6709
    6719
    6733

    FIRST
    ----------
    6737
    6761
    6763
    6779
    6781
    6791
    6793
    6803
    6823
    6827
    6829

    FIRST
    ----------
    6833
    6841
    6857
    6863
    6869
    6871
    6883
    6899
    6907
    6911
    6917

    FIRST
    ----------
    6947
    6949
    6959
    6961
    6967
    6971
    6977
    6983
    6991
    6997
    7001

    FIRST
    ----------
    7013
    7019
    7027
    7039
    7043
    7057
    7069
    7079
    7103
    7109
    7121

    FIRST
    ----------
    7127
    7129
    7151
    7159
    7177
    7187
    7193
    7207
    7211
    7213
    7219

    FIRST
    ----------
    7229
    7237
    7243
    7247
    7253
    7283
    7297
    7307
    7309
    7321
    7331

    FIRST
    ----------
    7333
    7349
    7351
    7369
    7393
    7411
    7417
    7433
    7451
    7457
    7459

    FIRST
    ----------
    7477
    7481
    7487
    7489
    7499
    7507
    7517
    7523
    7529
    7537
    7541

    FIRST
    ----------
    7547
    7549
    7559
    7561
    7573
    7577
    7583
    7589
    7591
    7603
    7607

    FIRST
    ----------
    7621
    7639
    7643
    7649
    7669
    7673
    7681
    7687
    7691
    7699
    7703

    FIRST
    ----------
    7717
    7723
    7727
    7741
    7753
    7757
    7759
    7789
    7793
    7817
    7823

    FIRST
    ----------
    7829
    7841
    7853
    7867
    7873
    7877
    7879
    7883
    7901
    7907

    1000 selected lines.

    Elapsed time: 00:00:05.07
    SQL >

    SY.

  • The Clause using SQL type

    Version
    SQL> select *
      2  from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - Production
    My query
    with tmp AS (
      select 1 as num, 'karthik' as txt from dual UNION select 2 as num, 'john' as txt from dual UNION select 3 as num, '' as txt  from dual UNION select 4 as num, '' as txt  from dual UNION
      select 14 as num, 'tom' as txt from dual UNION select 15 as num, '' as txt from dual UNION select 26 as num, 'sam' as txt from dual UNION
      select 27 as num, '' as txt from dual UNION select 28 as num, '' as txt from dual
    )
    select *
    from
    (
    select num,txt,rw,'G'||dense_rank() over(order by (num-rw)) grp_id
    from
    (
    select 
    num, txt,row_number() over(order by num) rw
    from tmp
    )
    )
    model partition by(grp_id)
          dimension by(num)
          measures(txt,cast(null as varchar2(4000)) as last_row_col)
          rules (last_row_col[(num)] = max(txt)[num < cv()])
    
    GRP_ID                                           NUM TXT     LAST_ROW_COL
    ----------------------------------------- ---------- ------- --------------------------------------------------------------------------------
    G1                                                 1 karthik 
    G1                                                 2 john    karthik
    G1                                                 3         karthik
    G1                                                 4         karthik
    G3                                                26 sam     
    G3                                                27         sam
    G3                                                28         sam
    G2                                                14 tom     
    G2                                                15         tom
    Desired output:
    GRP_ID     NUM     TXT     LAST_ROW_COL
    G1     1     karthik     karthik
    G1     2     john     
    G1     3          
    G1     4          john
    G3     26     sam     
    G3     27          
    G3     28          sam
    G2     14     tom     
    G2     15          tom
    i.e.within Group (GRP_ID) the LAST_ROW_COL column must have the most recent (order by num desc) not null not the value that is displayed in the last line of this group in particular.

    So, it should be 'john' for the rest of the null values in the group G1 (Kiss will remain as for num = 1) which should appear on the final line of this group in particular.

    Thanks in advance.

    Published by: RUSSO on January 2, 2012 04:18

    RUSSO says:

    I thought that this could be done easily using the power of the sql model clause

    with tmp AS (
                 select 1 as num, 'karthik' as txt from dual UNION ALL
                 select 2 as num, 'john' as txt from dual UNION ALL
                 select 3 as num, '' as txt  from dual UNION ALL
                 select 4 as num, '' as txt  from dual UNION ALL
                 select 14 as num, 'tom' as txt from dual UNION ALL
                 select 15 as num, '' as txt from dual UNION ALL
                 select 26 as num, 'sam' as txt from dual UNION ALL
                 select 27 as num, '' as txt from dual UNION ALL
                 select 28 as num, '' as txt from dual
                )
    select  grp_id,
            num,
            txt,
            last_row_col
      from  tmp
      model
        dimension by(row_number() over(order by num) rw)
        measures(num,txt,txt last_row_col,cast(null as varchar2(5)) grp_id)
        rules(
              grp_id[any]       = 'G' || dense_rank() over(order by num[cv()] - cv(rw)),
              last_row_col[rw > 1] order by rw = case
                                                   when last_row_col[cv()] is null then last_row_col[cv() - 1]
                                                   else last_row_col[cv()]
                                                 end,
              last_row_col[rw > 1] order by rw = case last_row_col[cv() + 1]
                                                   when last_row_col[cv()] then null
                                                   else last_row_col[cv()]
                                                 end
             )
    /
    
    GRP_I        NUM TXT     LAST_RO
    ----- ---------- ------- -------
    G1             1 karthik karthik
    G1             2 john
    G1             3
    G1             4         john
    G2            14 tom
    G2            15         tom
    G3            26 sam
    G3            27
    G3            28         sam
    
    9 rows selected.
    
    SQL> 
    

    SY.

    Published by: Solomon Yakobson January 2, 2012 09:35

  • SQL statements consume several times

    Hi all

    Recently I have faced the issue, 10 processes are taking place (means 10 sql statements) 4 declarations are huge time. For timebieng, I killed all sessions, but I know that's not just solve the problem. Can someone please explain briefly how to analyze the issue, root cause conclusion and giving if possible solutions for example please...

    What are the parameter that should be considered for the solution.


    Concerning

    KRISHNA

    Hello Krishna,

    The steps you need to take are explained in this thread:
    How to post a SQL tuning application HOW TO: post a request for tuning SQL - model poster statement

    In short:
    review the query plans, or ideally: trace/tkprof processes.
    After the output here, as well as your database version and optimizer parameter values.

  • SQL query setting

    Hi all
    My env is: oracle 10 g 2 on RHEL4.0, Dell power edge 7 series.
    My Q? is
    is - the AWR report useful to see why the slow query exec?
    Initially this setting must be considered for adjustment for a particular query.
    Kind regards
    KK

    Many things come into play with regard to tuning.

    Initially this setting must be considered for adjustment for a particular query.

    I always start with the execution plan.
    These discussions could help you understand about what you can do:
    When your query takes too long: when your query takes too long...
    How to post a SQL tuning request: HOW TO: post a request for tuning SQL - model poster statement

    In addition, you need to explore the
    Oracle® Database Performance Tuning Guide: http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm
    and do some research on this forum and http://asktom.oracle.com should give you more ideas.

  • You can optimize this sql?

    Hi,

    I believe that this sql can be improved, but honestly i don't know how.

    --------
                   Select * From Ctb_Mov m Where m.CodEmp = 1 and m.Plano='G' and
                   Cg Between '211' and '211'
                   and cx between '1' and '9999999'
                   and (M.GRUPO is NULL or
                  M.GRUPO in (select m1.GRUPO
                                        from ctb_mov M1
                                        where M1.CODEMP = m.codemp and
                                                  M1.PLANO = m.plano and
                                                  M1.cg = M.cg and
                                                  M1.cx = M.cx and
                                                  M1.GRUPO = M.GRUPO and
                                                  M1.datamov <= to_date('17092009','ddmmyyyy') and
                                                  M1.GRUPO <> 9999999
                                        group by M1.CODEMP, M1.PLANO, M1.cg,
                                                      M1.CX, M1.GRUPO
                                        having sum(M1.VLD - M1.VLC) <> 0))
    -------

    Suggestions?

    Regards

    Jomar

    [HOW: publish an application for tuning SQL - model showing statement | http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]

    This thread will give you a good overview on how to ask questions in this forum of the performance. After that you will get good answers!

  • Tuning SQL request

    Hello

    The goal for the following statement is so that it can be created as a point of view, but it takes 45 minutes minimum to complete. He returned about 200 000 lines and will gradually increase approximately 1,000 lines a day. Please bear with me, I couldn't get the output autotrace and dbms_xplan.display_cursor, because it takes ages to run. I've included output from v$ sql sql instead, hope this helps.

    Database version: 10.2.0.1

    Here are the coded sql statement:
    select tbl_4.col1,
    tbl_1.col2, 
    tbl_1.col3, 
    tbl_1.col4, 
    tbl_5.col5,
    tbl_1.col6,
    tbl_1.col7,
    tbl_2.col8,
    tbl_2.col9, 
    tbl_2.col10,
    tbl_2.col11,
    tbl_2.col12,
    tbl_3.col13,
    substr(tbl_6.col14, 1,  2),
    substr(tbl_6.col14, 4, 10),
    a.number_of_sales,
    decode (tbl_1.year, 99, 1999, 
                                 00, 2000,
                                 98,1998), 
    NVL2(tbl_7.col16, 'Yes', 'None'), 
    NVL2(tbl_8.col17, tbl_8.col1, 'N/A'), 
    NVL2(tbl_8.col18, tbl_8.col1, 'N'), 
    NVL2(tbl_8.col19, tbl_8.col1, 'N'), 
    NVL2(tbl_8.col20, tbl_8.col1, 'N'), 
    tbl_6.col21
    from tbl_1 
    join tbl_2 on (tbl_2.guid = tbl_1.guid)
    join tbl_3 on (tbl_3.guid = tbl_1.guid)
    join tbl_5 on (tbl_5.guid = tbl_1.guid)
    join tbl_6 on (tbl_6.guid = tbl_1.guid)
    join (select prod, number_of_sales
      from tbl_1
      where prod IN
              (select guid
                from tbl_6)
    MODEL
      PARTITION BY (country)
      DIMENSION BY (prod, year)
      MEASURES (prod as number_of_sales)
      IGNORE NAV
      UNIQUE DIMENSION
      RULES UPDATE SEQUENTIAL ORDER
      (
        number_of_sales[ANY, ANY] = 
          CASE WHEN count(number_of_sales)[ANY, '1999'] > 0
               THEN count(number_of_sales)[ANY, '1999'] 
               ELSE (CASE WHEN count(number_of_sales)[ANY, '2000'] > 0
               THEN count(number_of_sales)[ANY, '2000']
               ELSE (CASE WHEN count(number_of_sales)[ANY, '1998'] > 0
               THEN count(number_of_sales)[ANY, '1998']
               ELSE 0
          END)
          END)
          END
      ));a on (a.prod = tbl_1.prod)
    left outer join tbl_7 on (tbl_7.guid = tbl_1.guid)
    left outer join tbl_8 on (tbl_8.guid = tbl_1.guid)
    left outer join tbl_4 on (tbl_4.col22 = tbl_1.col23);
    Here is the output of the explain plan:
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------------------------
    
    Plan hash value: 2231252653
    
    ---------------------------------------------------------------------------------------------------------------
    | Id  | Operation                      | Name                 | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT               |                      | 60357 |    29M|       | 25428   (2)| 00:05:06 |
    |*  1 |  HASH JOIN RIGHT OUTER         |                      | 60357 |    29M|       | 25428   (2)| 00:05:06 |
    |   2 |   TABLE ACCESS FULL            | TBL_8                |   727 | 53798 |       |     6   (0)| 00:00:01 |
    |*  3 |   HASH JOIN RIGHT OUTER        |                      | 60357 |    25M|       | 25420   (2)| 00:05:06 |
    |   4 |    TABLE ACCESS FULL           | TBL_4                |   102 |  7854 |       |     3   (0)| 00:00:01 |
    |*  5 |    HASH JOIN                   |                      | 60357 |    20M|    17M| 25415   (2)| 00:05:05 |
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------------------------
    
    |*  6 |     HASH JOIN                  |                      | 60742 |    16M|    15M| 21282   (2)| 00:04:16 |
    |*  7 |      HASH JOIN                 |                      | 63196 |    15M|    14M| 19152   (2)| 00:03:50 |
    |*  8 |       HASH JOIN                |                      | 66797 |    13M|  5696K| 16578   (2)| 00:03:19 |
    |   9 |        VIEW                    |                      |   176K|  3619K|       |  6779   (2)| 00:01:22 |
    |  10 |         BUFFER SORT            |                      |   176K|    15M|       |            |          |
    |  11 |          SQL MODEL ORDERED     |                      |   176K|    15M|       |            |          |
    |* 12 |           HASH JOIN            |                      |   176K|    15M|  6152K|  6779   (2)| 00:01:22 |
    |  13 |            INDEX FAST FULL SCAN| TBL_6_PK             |   128K|  4643K|       |   214   (2)| 00:00:03 |
    |  14 |            TABLE ACCESS FULL   | TBL_1                |   466K|    25M|       |  4701   (2)| 00:00:57 |
    |* 15 |        HASH JOIN RIGHT OUTER   |                      |   176K|    32M|       |  7814   (2)| 00:01:34 |
    |  16 |         TABLE ACCESS FULL      | TBL_7                |   467 | 19614 |       |     3   (0)| 00:00:01 |
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------------------------
    
    |* 17 |         HASH JOIN              |                      |   176K|    25M|  7536K|  7808   (2)| 00:01:34 |
    |  18 |          TABLE ACCESS FULL     | TBL_6                |   128K|  6023K|       |   225   (3)| 00:00:03 |
    |  19 |          TABLE ACCESS FULL     | TBL_1                |   466K|    44M|       |  4701   (2)| 00:00:57 |
    |  20 |       TABLE ACCESS FULL        | TBL_3                |   321K|    12M|       |  1059   (3)| 00:00:13 |
    |  21 |      TABLE ACCESS FULL         | TBL_5                |   326K|    12M|       |   523   (3)| 00:00:07 |
    |  22 |     TABLE ACCESS FULL          | TBL_2                |   337K|    22M|       |  1919   (3)| 00:00:24 |
    ---------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------------------------
    
       1 - access("TBL_8"."GUID"(+)="TBL_1"."GUID")
       3 - access("TBL_4"."COL22"(+)="TBL_1"."COL23")
       5 - access("TBL_2"."GUID"="TBL_1"."GUID")
       6 - access("TBL_5"."GUID"="TBL_1"."GUID")
       7 - access("TBL_3"."GUID"="TBL_1"."GUID")
       8 - access("A"."PROD"="TBL_1"."PROD")
      12 - access("GUID"="GUID")
      15 - access("TBL_7"."GUID"(+)="TBL_1"."GUID")
      17 - access("TBL_6"."GUID"="TBL_1"."GUID")
    Here is the optimizer settings:
    NAME                                TYPE             VALUE
    ------------------------------------      -----------      ------------------------------
    optimizer_dynamic_sampling           integer          2
    optimizer_features_enable              string           10.2.0.1
    optimizer_index_caching               integer          0
    optimizer_index_cost_adj              integer          100
    optimizer_mode                       string           ALL_ROWS
    optimizer_secure_view_merging          boolean          TRUE
    db_file_multiblock_read_count           integer          16
    db_block_size                           integer          8192
    cursor_sharing                           string           EXACT
    
    SNAME                   PNAME                    PVAL1           PVAL2
    --------------------      --------------------      ----------      --------------------
    SYSSTATS_INFO          STATUS                COMPLETED
    SYSSTATS_INFO          DSTART                08-30-2005 15:04
    SYSSTATS_INFO          DSTOP                 08-30-2005 15:04
    SYSSTATS_INFO          FLAGS                       1
    SYSSTATS_MAIN         CPUSPEEDNW              484.974958
    SYSSTATS_MAIN         IOSEEKTIM                 10
    SYSSTATS_MAIN         IOTFRSPEED              4096
    SYSSTATS_MAIN         SREADTIM
    SYSSTATS_MAIN         MREADTIM
    SYSSTATS_MAIN         CPUSPEED
    SYSSTATS_MAIN         MBRC
    
    SNAME                     PNAME                PVAL1      PVAL2
    --------------------      -------------------- ---------- --------------------
    SYSSTATS_MAIN           MAXTHR
    SYSSTATS_MAIN           SLAVETHR
    Here is the TKProf output:
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.48       0.52         10         48        192           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch     4112     87.79    1099.84    3890789      61207          2      205504
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total     4114     88.28    1100.36    3890799      61255        194      205504
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 72  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
     205504  HASH JOIN RIGHT OUTER (cr=61207 pr=3890789 pw=3336846 time=1099316224 us)
        731   TABLE ACCESS FULL TBL_8 (cr=23 pr=11 pw=0 time=11508 us)
     205504   HASH JOIN RIGHT OUTER (cr=61184 pr=3890778 pw=3336846 time=1098446711 us)
        102    TABLE ACCESS FULL TBL_4 (cr=7 pr=6 pw=0 time=10685 us)
     205504    HASH JOIN  (cr=61177 pr=3890772 pw=3336846 time=1097406100 us)
     205504     HASH JOIN  (cr=52309 pr=3876731 pw=3331582 time=1092251311 us)
     205504      HASH JOIN  (cr=49818 pr=3872092 pw=3327095 time=1088296724 us)
     205504       HASH JOIN  (cr=44805 pr=3862788 pw=3322741 time=1083430636 us)
     205504        VIEW  (cr=22340 pr=3824447 pw=3312710 time=1064542304 us)
     205504         BUFFER SORT (cr=22340 pr=3824447 pw=3312710 time=1064131291 us)
     205504          SQL MODEL ORDERED (cr=22340 pr=3823920 pw=3312183 time=79100422 us)
     205504           HASH JOIN  (cr=22340 pr=24845 pw=3829 time=22189967 us)
     135074            INDEX FAST FULL SCAN TBL_6_PK (cr=1011 pr=869 pw=0 time=955438 us)(object id 103575)
     469544            TABLE ACCESS FULL TBL_1 (cr=21329 pr=17067 pw=0 time=12229819 us)
     205504        HASH JOIN RIGHT OUTER (cr=22465 pr=34519 pw=6209 time=18445327 us)
        497         TABLE ACCESS FULL TBL_7 (cr=7 pr=3 pw=0 time=15547 us)
     205504         HASH JOIN  (cr=22458 pr=34516 pw=6209 time=17560031 us)
     135074          TABLE ACCESS FULL TBL_6 (cr=1082 pr=1059 pw=0 time=157502 us)
     469544          TABLE ACCESS FULL TBL_1 (cr=21376 pr=16734 pw=0 time=11749176 us)
     341927       TABLE ACCESS FULL TBL_3 (cr=5013 pr=4950 pw=0 time=2080124 us)
     341935      TABLE ACCESS FULL TBL_5 (cr=2491 pr=152 pw=0 time=5129098 us)
     341932     TABLE ACCESS FULL TBL_2 (cr=8868 pr=8777 pw=0 time=3436425 us)
    Here is the output from v$ sql
    SQL_TEXT     select tbl_4…
    SQL_FULLTEXT     
    SQL_ID     bh7z3jzt6vw06
    SHARABLE_MEM     66824
    PERSISTENT_MEM     25756
    RUNTIME_MEM     23808
    SORTS     1
    LOADED_VERSIONS     1
    OPEN_VERSIONS     1
    USERS_OPENING     1
    FETCHES     1
    EXECUTIONS     1
    PX_SERVERS_EXECUTIONS     0
    END_OF_FETCH_COUNT     0
    USERS_EXECUTING     1
    LOADS     1
    FIRST_LOAD_TIME     2009-08-14/15:59:08
    INVALIDATIONS     0
    PARSE_CALLS     1
    DISK_READS     3905090
    DIRECT_WRITES     3340053
    BUFFER_GETS     62290
    APPLICATION_WAIT_TIME     0
    CONCURRENCY_WAIT_TIME     0
    CLUSTER_WAIT_TIME     0
    USER_IO_WAIT_TIME     1042926858
    PLSQL_EXEC_TIME     0
    JAVA_EXEC_TIME     0
    ROWS_PROCESSED     50
    COMMAND_TYPE     3
    OPTIMIZER_MODE     ALL_ROWS
    OPTIMIZER_COST     25428
    OPTIMIZER_ENV     E289FB.......
    OPTIMIZER_ENV_HASH_VALUE     1151412318
    PARSING_USER_ID     72
    PARSING_SCHEMA_ID     72
    PARSING_SCHEMA_NAME     DATA
    KEPT_VERSIONS     0
    ADDRESS     569F083C
    TYPE_CHK_HEAP     00
    HASH_VALUE     4067291142
    OLD_HASH_VALUE     1777942244
    PLAN_HASH_VALUE     2231252653
    CHILD_NUMBER     0
    SERVICE     SYS$USERS
    SERVICE_HASH     0
    MODULE     SQL Developer
    MODULE_HASH     0
    ACTION     
    ACTION_HASH     0
    SERIALIZABLE_ABORTS     0
    OUTLINE_CATEGORY     
    CPU_TIME     81093819
    ELAPSED_TIME     1122285962
    OUTLINE_SID     
    CHILD_ADDRESS     52541620
    SQLTYPE     6
    REMOTE     N
    OBJECT_STATUS     VALID
    LITERAL_HASH_VALUE     0
    LAST_LOAD_TIME     2009-08-14/15:59:08
    IS_OBSOLETE     N
    CHILD_LATCH     3
    SQL_PROFILE     
    PROGRAM_ID     101200
    PROGRAM_LINE#     2
    EXACT_MATCHING_SIGNATURE     4.3484E+18
    FORCE_MATCHING_SIGNATURE     1.5863E+19
    LAST_ACTIVE_TIME     14-AUG-09
    BIND_DATA     

    There is a large gap between the time cpu and elapsed time. So a lot of time - more than 1000 seconds of 1100 seconds in total - were spent waiting. Please repeat track/tkprof step you took, but this time include the record of the expectations. You can do, for example, by launching:

    alter session set events '10046 trace name context forever, level 8'
    

    I think for now, is that your PGA is undersized for this query, because the time is especially dedicated to step "BUFFER FATE." If the report of tkprof including wait, reveals a lot of 'direct path read temp' and 'direct path write temp', then we know for sure.

    Kind regards
    Rob.

  • How to add constraints not null

    Data modeling Version 4.1.1.888 SQL

    How to add constraints not null in sql modeling data and rename the default constraint name that is getting generated when marking column as required.

    You can edit the template for the names of constraint not Null under properties-> setting->-> models naming standards. Change one marked 'not forced Null. Then, under preferences-> Data Modeler-> DDL, you must uncheck "generate short form constraint NOT NULL".

  • problem with a loop in a cursor

    Hello

    I wrote following PL/SQL procedure to create indexes on a table to particular warehouse. WAR_ETL_INDEX table is a table of store, I created that contains the table name, column name, and the name of the index of this column. I pick up all these details in the WAR_ETL_INDEX table and create indexes using the following procedure. Now, after compiling the code, when I am trying to execute the following procedure with

    "set serveroutput on .

    EXEC RECREATE_INDEX("W_General_D"); "it seems that it is not picking all the files lets assume if the cursor has 3 records this code tries to run create 3 index but all three times its operation for the first record." Thus, its closure for 3 times, but for all his race for the first record only loop. Could you please review the code and share if you find any problem.

    CREATE or REPLACE PROCEDURE RECREATE_INDEX (par_table_name VARCHAR2)

    IS

    INDEX_NAME WAR_ETL_INDEX. INDEX_NAME % TYPE;

    WAR_ETL_INDEX OF COLUMN_NAME. COLUMN_NAME % TYPE;

    l_sql DEFAULT CLOB "TABLESPACE in CREATE BITMAP INDEX INDEX_NAME ON TABLE_NAME ('COLUMN_NAME') 'P1_DW_IDX" ";

    CURSOR C1 IS

    SELECT INDEX_NAME, COLUMN_NAME

    WAR_ETL_INDEX WHERE TABLE_NAME FROM = par_table_name;

    BEGIN

    OPEN C1;

    LOOP

    FETCH C1 INTO INDEX_NAME, COLUMN_NAME;

    WHEN EXIT C1% NOTFOUND;

    l_sql: = REPLACE (REPLACE (REPLACE(l_sql,'INDEX_NAME',INDEX_NAME), 'TABLE_NAME', par_table_name), 'COLUMN_NAME', COLUMN_NAME);

    dbms_output.put_line (l_sql);

    EXECUTE immediate l_sql;

    END LOOP;

    commit;

    CLOSE C1;

    END RECREATE_INDEX;

    You need to reset your variable l_sql with the SQL model on each loop.  You have no need for a commit, DDL has an implicit validation thus creating an index will do.   Try something like this...

    CREATE or replace PROCEDURE Recreate_index (par_table_name VARCHAR2) IS

    l_sql CLOB.

    CLOB constant l_templatesql: = "TABLESPACE in CREATE BITMAP INDEX INDEX_NAME ON TABLE_NAME ('COLUMN_NAME') 'P1_DW_IDX" ";

    BEGIN

    FOR rec in (SELECT index_name,

    column_name

    OF war_etl_index

    WHERE table_name = par_table_name)

    LOOP

    l_sql: = l_templatesql; -Reset DDL index

    l_sql: = Replace (replace (Replace (l_sql, 'INDEX_NAME', rec.index_name))

    (('TABLE_NAME', par_table_name), 'COLUMN_NAME', rec.column_name);

    dbms_output. Put_line (l_sql);

    EXECUTE IMMEDIATE l_sql;

    END LOOP;

    END recreate_index;

  • Y at - it a keyboard shortcut to insert snippets?

    Is it possible to insert a snippet without resorting to code snippets panel? Something like completion for extracts Insight would be much more useful.

    That's why I find the SQL models is superior because they are related in the function code insight

Maybe you are looking for