Subquery factoring with "with" - slow

I have a query of the form
with t1 as ( select-query-with-grouping )
, t2 as (other-query-with-grouping )
, t3 as (another-query-with-grouping )
select * from t1
fulll outer join t2 on t1.KeyColumn = t2.KeyColumn
full outer join t3 on t1.KeyColumn = t3.KeyColumn or t2.KeyColumn = t3.KeyColumn
Each of the 3 grouped select queries runs very quickly (under a second) and returns about 800 rows.
But in combination, the query takes about a minute to return, also about 800 rows.
If I select the data into temp tables and then join against that, it is very fast. About a second.
Question is - shouldn't i be seeing about the same performance using "with ..." as with temp tables?
I tried applying the "materialize" hint to the inner queries, but it had no effect.
Any suggestions about how i can make "With" behave like using temp tables?
Thanks in advance
Edited by: 854248 on Apr 22, 2011 7:11 PM

Thanks for your reply.
The inner queries do use inner joins to an other table common table. There is nothing that can be moved outside though.
I do see that if I omit either of the pieces of the OR in the second outer join - that is, just join one or the other of t1 or t2, then the query is quite fast (and returns just a few more rows). But, the point of this query is to get all the rows from N tables that share a common key column. And I think that means that as each tX is joined, it has to be t1.key = tX.key or t2.key = tX.key or t3.key=tX.key ... That's how we write the query in SqlServer 2k5/8 (also using the "with" syntax) where it is quite fast with this same data set.
From my reading about the "with" feature, the oracle optimizer should "materialize" the tN pieces of the query using some sort of in memory temp table like approach. It appears that it is either not doing that, or whatever it is doing is performing very badly. As i say, if I create tN global temporary tables from these pieces and then do the full outer join, it is very fast. I wonder if that is a 10g/11g feature, or a limitation of my 10g express edition or something. That said, I see the same trend in a different data set on an 11g standard edition system that we use in QA. I have tried adding the /*+ materialize */ hint to both systems, to no avail.

Similar Messages

  • Subquery Factoring -Performance Issue

    Hi experts,
    Oracle 10G
    select
    a.colums,
    b.columns
    from
    ( select
    Colums
    from
    F ,
    (select
    columns
    from
    bigtable
    where
    <condition with recdate and modified date with timezone convertions Given as in end of this qury)
    ) a,
    ( select
    Colums
    from
    tables,
    (select
    columns
    from
    bigtable
    where
    <condition with recdate and modified date with timezone convertions Given as in end of this qury)
    ) b
    (TO_DATE(TO_CHAR(FROM_TZ(CAST(CF.RECDT as timestamp),'GMT') at time zone 'America/Chicago','YYYY-MM-DD
    HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')
         BETWEEN TO_DATE('01-JAN-2009 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('08-JAN-2009 00:00:00', 'DD-MON-YYYY
    HH24:MI:SS')) OR
    (TO_DATE(TO_CHAR(FROM_TZ(CAST(CF.MODIFID_DT as timestamp),'GMT') at time zone 'America/Chicago','YYYY-MM-DD
    HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')
    BETWEEN TO_DATE('01-JAN-2009 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('08-JAN-2009 00:00:00', 'DD-MON-YYYY
    HH24:MI:SS'))
    Recdt - indexed
    Modifieddt - not iddexed
    bigtable used many times in select to avoid Subquery factoring used (with select) but it increased cost as per explain plan in sqldevleoper please suggest me to increase performance
    Lots of thanks,
    Kalinga

    now the above query use as
    with subfact as
    ( select
    select
    columns
    from
    bigtable
    where
    <condition with recdate and modified date
    select
    a.colums,
    b.columns
    from
    ( select
    Colums
    from
    F ,
    subfact
    where condition
    ) a,
    ( select
    Colums
    from
    tables,
    subfact
    where condition
    ) b
    it is cost increased in nested loop in explain plan why? is thre any other detail required.

  • WITH Subquery Factoring OR "Scalar SubqueriesRun Another Query per row

    Hi Experts
    Please suggest
    which one query is better
    Involved table p is of size 2GB and c1/c2 of size 800M.
    And we have to run a report on p which will do FTS (no where clause on p)
    So FTS on 2 GB table and then running Another Query per row .. so results job very slow
    1)  Select p.id,
             (select sum(q1) from c1 where c1.id = p.id) c1_sum1,
             (select sum(q2) from c2 where c2.id = p.id) c2_sum2
       from p
    2)
    WITH Subquery Factoring
    with c1_vw as
    (select id, sum(q1) c1_sum1
        from c1
             group by id),
       c2_vw as
       (select id, sum(q2) c2_sum2
           from c2
          group by id),
       c1_c2 as
       (select c1.id, c1.c1_sum1, c2.c2_sum2
           from c1_vw c1, c2_vw c2
          where c1.id = c2.id )
       select p.id, c1_sum1, c2_sum2
          from p, c1_c2
         where p.id = c1_c2.id
       / 10.2..0.4
    AIX 5.3
    Thanks In Advance
    ivw

    ivw wrote:
    which one query is betterThe better query IMHO is the one that returns the the correct results in the shortest amount of time using the least system resources (the last two items usually happen at the same time). Maintainability is an issue too. Which one do you like best?
    Its hard to say which query will run best without running both, getting execution plans, and run-time statistics. At a pure guess I would think all things being equal they would have similar performance but do not really know.

  • Bug in WITH clause (subquery factoring clause) in Oracle 11?

    I'm using WITH to perform a set comparison in order to qualify a given query as correct or incorrect regarding an existing solution. However, the query does not give the expected result - an empty set - when comparing the solution to itself in Oracle 11 whereas it does in Oracle 10. A minimal example os posted below as script. There are also some observations about changes to the tables or the query that make Oracle 11 returning correct results but in my opinion these changes must not change the semantics of the queries.
    Is this a bug or am I getting something wrong? The Oracle versions are mentioned in the script.
    -- Bug in WITH clause (subquery factoring clause)
    -- in Oracle Database 11g Enterprise Edition 11.2.0.1.0?
    DROP TABLE B PURGE;
    DROP TABLE K PURGE;
    DROP TABLE S PURGE;
    CREATE TABLE S (
         m     number NOT NULL,
         x     varchar2(30) NOT NULL
    CREATE TABLE K (
         k char(2) NOT NULL,
         x varchar2(50) NOT NULL
    CREATE TABLE B (
         m     number NOT NULL ,
         k char(2) NOT NULL ,
         n     number
    INSERT INTO S VALUES(1, 'h');
    INSERT INTO S VALUES(2, 'l');
    INSERT INTO S VALUES(3, 'm');
    INSERT INTO K VALUES('k1', 'd');
    INSERT INTO K VALUES('k2', 'i');
    INSERT INTO K VALUES('k3', 'm');
    INSERT INTO K VALUES('k4', 't');
    INSERT INTO K VALUES('k5', 't');
    INSERT INTO K VALUES('k6', 's');
    INSERT INTO B VALUES(1, 'k1', 40);
    INSERT INTO B VALUES(1, 'k2', 30);
    INSERT INTO B VALUES(1, 'k4', 50);
    INSERT INTO B VALUES(3, 'k1', 10);
    INSERT INTO B VALUES(3, 'k2', 20);
    INSERT INTO B VALUES(3, 'k1', 30);
    INSERT INTO B VALUES(3, 'k6', 90);
    COMMIT;
    ALTER TABLE S ADD CONSTRAINT S_pk PRIMARY KEY (m);
    ALTER TABLE K ADD CONSTRAINT K_pk PRIMARY KEY (k);
    ALTER TABLE B ADD CONSTRAINT B_S_fk
    FOREIGN KEY (m) REFERENCES S(m) ON DELETE CASCADE;
    CREATE OR REPLACE VIEW v AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC;
    -- Query 1: Result should be 0
    WITH q AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    SELECT COUNT(*)
    FROM
    SELECT * FROM q
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM q
    -- COUNT(*)
    -- 6
    -- 1 rows selected
    -- Query 2: Result set should be empty (Query 1 without counting)
    WITH q AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    SELECT *
    FROM
    SELECT * FROM q
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM q
    -- M N
    -- null 10
    -- null 30
    -- null 40
    -- 1 40
    -- 3 10
    -- 3 30
    -- 6 rows selected
    -- Observations:
    -- Incorrect results in Oracle Database 11g Enterprise Edition 11.2.0.1.0:
    -- Query 1 returns 6, Query 2 returns six rows.
    -- Correct in Oracle Database 10g Enterprise Edition 10.2.0.1.0.
    -- Correct without the foreign key.
    -- Correct if attribute x is renamed in S or K.
    -- Correct if attribute x is left out in S.
    -- Correct without the ORDER BY clause in the definition of q.
    -- Only two results if the primary key on K is left out.
    -- Correct without any change if not using WITH but subqueries (see below).
    -- Fixed queries
    -- Query 1b: Result should be 0
    SELECT COUNT(*)
    FROM
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    -- COUNT(*)
    -- 0
    -- 1 rows selected
    -- Query 2b: Result set shoud be empty (Query 1b without counting)
    SELECT *
    FROM
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    -- M N
    -- 0 rows selected

    You're all gonna love this one.....
    The WITH clause works. But not easily.
    Go ahead, build the query, (as noted in a recent thread, I, too, always use views), set the grants and make sure DISCOVERER and EULOWNER have SELECT privs.
    1. Log into Disco Admin as EULOWNER. Trust me.
    2. Add the view as a folder to the business area.
    3. Log into Disco Desktop as EULOWNER. Don't laugh. It gets better.
    4. Build the workbook and the worksheet (or just the worksheet if apropos)
    5. Set the appropriate "sharing" roles and such
    6. Save the workbook to the database.
    7. Save the workbook to your computer.
    8. Log out of Desktop.
    9. Log back into Desktop as whatever, whoever you usually are to work.
    10. elect "open existing workbook"
    11. Select icon for "open from my computer". See? I told you it would get better!
    12. Open the save .dis file from your computer.
    13. Save it to the database.
    14. Open a web browser and from there, you're on your own.
    Fortran in VMS. Much easier and faster. I'm convinced the proliferation of the web is a detriment to the world at large...On the other hand, I'm also waiting for the Dodgers to return to Brooklyn.

  • How to use subquery factoring ("with" clause) in OWB?

    Hi,
    Is it possible to use subquery factoring (popularly known as "with" clause) in OWB 10gR2? I have a mapping with a splitter and union-all, which generates a query that has repeated scans of the same table. Subquery Factoring would be very useful here. I think this is a very common situation, so, I hope there's a way to achieve this. (If not in this version, this would be my wishlist item for the next version.)
    Appreciate your help.
    Regards,
    Rahul

    Hi Rahul,
    I'm afraid you have to put this on your wishlist. You may put the query with the "with"-clause into a view (or table function if you need parameters) if performance is too bad. But that is somehow against the idea (and benefits) of owb.
    Another possibility is to use a temporary table and spilt the mappings into two parts: first fill the temp table, then the target table.
    Regards,
    Carsten.

  • Recursive WITH (Recursive Subquery Factoring) Never Returns

    11.2.0.2 database on Windows, SQL Developer Version 3.2.20.09, build MAIN-09.87 (Database and SQL Developer are on the same machine. I have also tried connecting to a Linux 11.2 database and have the same results.)
    I've been doing some simple testing with recursive WITH (Recursive Subquery Factoring) and when I run this following statement in SQL*Plus it returns instantly. However when running in SQL Developer it never returns, I've let it run for quite a long time (172 seconds) and gotten nothing, I finally kill the statement. Once I ran it and even killing the job didn't come back. I can get an explain plan but if I try to run it, run as script or autotrace it never returns. I have only one plan in the plan_table for this test, and it's only 4 lines long. No errors, no messages.
    WITH get_plan (query_plan, id, planlevel) as
    select ' '||operation||' '||options||' '||object_name query_plan, id, 1 planlevel
    from plan_table
    where id = 0
    union all
    select lpad(' ',2*planlevel)||p.operation||' '||p.options||' '||p.object_name query_plan, p.id, planlevel+1
    from get_plan g, plan_table p
    where g.id = p.parent_id
    SELECT QUERY_PLAN FROM GET_PLAN ORDER BY PLANLEVEL;

    Hi Jeff, using either give the same results. The query is "running", as is the little graphic with the bouncing gray bar is moving back and forth saying either "Query Results" or "Scriptrunner Task" as appropriate.
    OK this is odd. I run a count(*) on plan_table in SQL*Plus and get 4, in SQL Developer I get 487. Hun? That makes no sense I'm connect as the same user in each. Where are all these other entries coming from and why can't I see them in SQL Plus? Does SQL Developer have it's own PLAN_TABLE?
    **EDIT --- Yes that seems to be the case. The PLAN_ID I see in SQL Plus doesn't even exist in the SQL Deveropler version of the table. OK that's good to know. I assume the plan_table for SQL Developer is local to it somehow? It's not in the database as best I can see.
    Edited by: Ric Van Dyke on Feb 7, 2013 5:19 PM

  • With clause of select (subquery factoring)

    I've got a script that looks like this:
    with X as (select * from atable)
    select x1.*, x2.*
    from X x1,
    X x2
    This works perfectly well in SQL*Plus, in PL/SQL, etc. Yet when I try to add it as "New Folder from Database" to an existing Business area in Discoverer, I get the infamous "ORA-03001 Unimplemented Feature".
    What am I doing wrong?
    Oracle 9i, Disco 9.0.4

    Hi,
    You will have to define a database view containing your query and load the view into your database. I don't think you can use subquery factoring in a custom folder.
    Rod West

  • I am having a problem with very slow start up after expanding RAM on my 2009 Mac Pro.

    I am having a problem with very slow start up after expanding RAM on my 2009 Mac Pro (8 Core 2.93GHz). When I run the Mac Pro with 2 x 2Gb RAM it takes 4 seconds before the gray screen, chime and spinning wheel appear.However when I expand the RAM to 20GB the grey screen and chimes appear after a long 20+ second black screen.
    The RAM modules are paored  2 x 4GB Crucial CT51272BA1339.M18FMR and  6 x 2GB SAMSUNG M391B5673FH0-CH9, all DDR3 ECC.
    Reading articles on the internet, I thought it may be damaged RAM modules, but I have completed memtest and all are okay. I have tried changing the pairs around and if I use any paired 2 modules the Mac Pro starts normally, only when I try running more than 2 modules the delayed start up happens. (black screen 20 Seconds)
    I also have tried PRAM and SMU resets after changing the RAM setups, and the issues always occurs when I have more than 2 modules. As you can see I have 6 SAMSUNG modules and even with identical modules the issue happens, when increasing the RAM to more than 2 modules.
    The Mac Pro runs fine after the start up screen and can see all the modules, but has anyone else come across this issue, or have any ideas as to why my Mac Pro is taking 20 seconds to start up with 20 GB RAM?

    Hi there. Thanks for your comments.
    I have tried all the different combinations of RAM setup, and as stated in my initial topic, the Mac Pro boot up time only slows when I have more that 2 modules. Where I place these does not seem to make a difference.
    I have taken the Mac Pro to an Apple Reseller technician yesterday and they where not able to find any RAM errors. Apparently the boot up time is within Apple's acceptable parameters for this set up.
    Could anyone that is running a Mac Pro 2009 with more that 4 modules of RAM, please let me know if the boot up time is normal. ( the time it takes from pressing the power button to seeing the gray screen around 16 - 20 seconds)
    Or is anyone else having the same issues?
    thanks for your responce

  • Materialize a Subquery without using "with" clause

    Hi experts,
    We know that we can materialize a subquery as below :
    with sub_q as
    ( select /*+ materialize */ a,b,c from table_name )
    select * from sub_q;
    My question is, is there any other way to force a subquery be materialized by writing straight as below ?:
    select * from
    ( select a,b,c from table_name );
    Thanks in advance.

    user503699 wrote:
    You sure about that? I don't think so. ;)??? Do you understand what materialize is? I don't think so. Feel the difference:
    SQL> create table emp1 as select * from emp
      2  /
    Table created.
    SQL> explain plan for
      2  with t as (
      3             select /*+ materialize */ * from emp1 where deptno = 10
      4            )
      5  select * from t where job = 'CLERK'
      6  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 481100556
    | Id  | Operation                  | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT           |                            |     3 |   261 |     5   (0)| 00:00:01 |
    |   1 |  TEMP TABLE TRANSFORMATION |                            |       |       |            |          |
    |   2 |   LOAD AS SELECT           |                            |       |       |            |          |
    |*  3 |    TABLE ACCESS FULL       | EMP1                       |     3 |   261 |     3   (0)| 00:00:01 |
    |*  4 |   VIEW                     |                            |     3 |   261 |     2   (0)| 00:00:01 |
    |   5 |    TABLE ACCESS FULL       | SYS_TEMP_0FD9D6608_11C6B35 |     3 |   261 |     2   (0)| 00:00:01 | <== SYS_TEMP_0FD9D6608_11C6B35 is a metrialized table t
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - filter("DEPTNO"=10)
       4 - filter("JOB"='CLERK')
    Note
       - dynamic sampling used for this statement
    22 rows selected.
    SQL> explain plan for
      2  select * from (select /*+ materialize */ * from emp1 where deptno = 10) t where job = 'CLERK'
      3  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 2226897347
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    87 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP1 |     1 |    87 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter("EMP1"."JOB"='CLERK' AND "DEPTNO"=10)
    Note
       - dynamic sampling used for this statement
    17 rows selected.
    SQL> SY

  • Slow query with WITH and JOIN

    Hi,
    This code is taking too much time to complete :
    WITH rawData AS -- 563 rows in 0.07s OR 59 rows in 0.02s
    SELECT
         date_releve AS x1,
         index_corrige AS y1,
         LEAD(date_releve) OVER (PARTITION BY id_compteur ORDER BY date_releve) AS x2,
         LEAD(index_corrige) OVER (PARTITION BY id_compteur ORDER BY date_releve) AS y2,
         id AS id_releve,
         id_compteur
    FROM V_relevesCorriges
    meteoData AS -- 1082 rows in 1.34s OR 116 rows in 0.16s
    SELECT avg(meteo.valeur) AS meteoValue, x2 AS dateMeteo, id_variable, id_releve, id_compteur
    FROM meteo, rawData
    WHERE date_meteo <= x2 AND date_meteo > x1
    GROUP BY id_releve, id_variable, x2, id_compteur
    ORDER BY x2
    consoData AS -- 1104 rows in 1.43s, 117 rows in 0.2s
    SELECT
    to_char(x1, 'DD.MM.YYYY') || ' - ' || to_char(x2, 'DD.MM.YYYY') AS periode,
         meteoValue AS meteo_moyenne,
         (y2 - y1) / nullif((x2 - x1),0) AS conso_par_jour,
         (y2 - y1) AS conso,
         rawData.id_releve id_releve,
         meteoData.id_variable id_variable,
         meteoData.id_compteur id_compteur
    FROM rawData LEFT OUTER JOIN meteoData ON rawData.id_releve = meteoData.id_releve
    ORDER BY x2
    SELECT periode, meteo_moyenne, conso_par_jour, consoData.id_variable id_variable, consoData.id_releve id_releve, id_compteur -- 1104 rows in 1.51s, 116 rows in 1.34s
    FROM consoData LEFT OUTER JOIN diagnostic2 ON consoData.id_releve = diagnostic2.id_releve AND consoData.id_variable = diagnostic2.id_variable
    WHERE Id_compteur = 4If I remove "WHERE Id_compteur = 4" on the last line, it makes almost no difference in execution time. Without this WHERE clause, it returns 1104 rows in 1.51s, with it it returns 116 rows in 1.34s.
    I'm saying that it takes too long because when I move this WHERE clause into "consoData" (WHERE meteoData.consoData=4), it returns 116rows in 0.2s, for getting the same data output. If I remove the LEFT OUTER JOIN diagnostic2 (last but one line) it also takes 0.2s.
    I think that the solution would be to force "WHERE Id_compteur=..." to take effect before it joins the "diagnostic2" table, but don't know how to do it.
    The subquery that takes much time when returning all rows is "meteoData".
    This code is meant to be a VIEW, so "WHERE Id_compteur=..." will not be included in it but passed when querying the view. I tested it as a VIEW, same problem.
    Explain plan :
    Plan hash value: 724835998
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 16364 | 1342K| | 586 (4)| 00:00:08 |
    | 1 | TEMP TABLE TRANSFORMATION | | | | | | |
    | 2 | LOAD AS SELECT | DIAGNOSTIC2 | | | | | |
    | 3 | WINDOW SORT | | 563 | 15764 | | 12 (25)| 00:00:01 |
    | 4 | VIEW | V_RELEVESCORRIGES | 563 | 15764 | | 11 (19)| 00:00:01 |
    | 5 | SORT GROUP BY | | 563 | 56300 | | 11 (19)| 00:00:01 |
    | 6 | VIEW | | 563 | 56300 | | 10 (10)| 00:00:01 |
    |* 7 | HASH JOIN RIGHT OUTER | | 563 | 25335 | | 10 (10)| 00:00:01 |
    | 8 | TABLE ACCESS FULL | COMPTEURS | 22 | 132 | | 3 (0)| 00:00:01 |
    | 9 | VIEW | | 563 | 21957 | | 7 (15)| 00:00:01 |
    |* 10 | HASH JOIN OUTER | | 563 | 26461 | | 7 (15)| 00:00:01 |
    | 11 | TABLE ACCESS FULL | RELEVES | 563 | 12949 | | 3 (0)| 00:00:01 |
    | 12 | VIEW | V_CORRECTIONDATA | 563 | 13512 | | 3 (0)| 00:00:01 |
    |* 13 | VIEW | | 563 | 28150 | | 3 (0)| 00:00:01 |
    | 14 | WINDOW SORT | | 563 | 67560 | | 3 (0)| 00:00:01 |
    | 15 | VIEW | | 563 | 67560 | | 3 (0)| 00:00:01 |
    | 16 | NESTED LOOPS OUTER| | 563 | 14638 | | 3 (0)| 00:00:01 |
    | 17 | TABLE ACCESS FULL| RELEVES | 563 | 12949 | | 3 (0)| 00:00:01 |
    |* 18 | INDEX UNIQUE SCAN| COMPTEURS_PK | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 19 | HASH JOIN RIGHT OUTER | | 16364 | 1342K| | 573 (4)| 00:00:07 |
    | 20 | INDEX FULL SCAN | DIAGNOSTIC2_PK | 4 | 24 | | 1 (0)| 00:00:01 |
    | 21 | VIEW | | 16364 | 1246K| | 572 (4)| 00:00:07 |
    | 22 | SORT ORDER BY | | 16364 | 1661K| 3864K| 572 (4)| 00:00:07 |
    |* 23 | HASH JOIN | | 16364 | 1661K| | 179 (9)| 00:00:03 |
    | 24 | VIEW | | 1157 | 55536 | | 3 (0)| 00:00:01 |
    | 25 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6657_90A96D1D | 1157 | 55536 | | 3 (0)| 00:00:01 |
    |* 26 | VIEW | | 7963 | 435K| | 175 (8)| 00:00:03 |
    | 27 | SORT GROUP BY | | 7963 | 311K| 1768K| 175 (8)| 00:00:03 |
    | 28 | MERGE JOIN | | 26409 | 1031K| | 23 (48)| 00:00:01 |
    | 29 | SORT JOIN | | 1157 | 28925 | | 4 (25)| 00:00:01 |
    | 30 | VIEW | | 1157 | 28925 | | 3 (0)| 00:00:01 |
    | 31 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6657_90A96D1D | 1157 | 55536 | | 3 (0)| 00:00:01 |
    |* 32 | FILTER | | | | | | |
    |* 33 | SORT JOIN | | 9130 | 133K| | 11 (19)| 00:00:01 |
    | 34 | TABLE ACCESS FULL | METEO | 9130 | 133K| | 9 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    7 - access("RELEVES"."ID_COMPTEUR"="COMPTEURS"."ID"(+))
    10 - access("RELEVES"."ID_COMPTEUR"="V_CORRECTIONDATA"."ID_COMPTEUR"(+))
    filter("RELEVES"."DATE_RELEVE">="V_CORRECTIONDATA"."DATE_CHANGEMENT"(+))
    13 - filter("CHG_COMPTEUR"=1 AND "ID_COMPTEUR"="ID_COMPTEUR_CORR")
    18 - access("RELEVES"."ID_COMPTEUR"="COMPTEURS"."ID"(+))
    19 - access("CONSODATA"."ID_VARIABLE"="DIAGNOSTIC2"."ID_VARIABLE"(+) AND
    "CONSODATA"."ID_RELEVE"="DIAGNOSTIC2"."ID_RELEVE"(+))
    23 - access("RAWDATA"."ID_RELEVE"="METEODATA"."ID_RELEVE")
    26 - filter("METEODATA"."ID_COMPTEUR"=4)
    32 - filter("DATE_METEO">"X1")
    33 - access(INTERNAL_FUNCTION("DATE_METEO")<=INTERNAL_FUNCTION("X2"))
    filter(INTERNAL_FUNCTION("DATE_METEO")<=INTERNAL_FUNCTION("X2"))Oracle database version : 10.2.0.4.0, I'm accessing it through APEX version 4.1.1.00.23
    I hope that my question is not too fuzzy..

    Perhaps you need to push the filter on id_compteur up to the rawdata subquery?
    Try:
    WITH rawdata
         AS -- 563 rows in 0.07s OR 59 rows in 0.02s
           (SELECT date_releve AS x1,
                   index_corrige AS y1,
                   LEAD(date_releve)
                     OVER (PARTITION BY id_compteur ORDER BY date_releve)
                     AS x2,
                   LEAD(index_corrige)
                     OVER (PARTITION BY id_compteur ORDER BY date_releve)
                     AS y2,
                   id AS id_releve,
                   id_compteur
            FROM   v_relevescorriges
            WHERE  id_compteur = 4),
         meteodata
         AS -- 1082 rows in 1.34s OR 116 rows in 0.16s
           (SELECT AVG(meteo.valeur) AS meteovalue,
                   x2 AS datemeteo,
                   id_variable,
                   id_releve,
                   id_compteur
            FROM   meteo, rawdata
            WHERE  date_meteo <= x2
            AND    date_meteo > x1
            GROUP BY id_releve,
                     id_variable,
                     x2,
                     id_compteur
            ORDER BY x2),
         consodata
         AS -- 1104 rows in 1.43s, 117 rows in 0.2s
           (SELECT TO_CHAR(x1, 'DD.MM.YYYY') || ' - ' || TO_CHAR(x2, 'DD.MM.YYYY')
                     AS periode,
                   meteovalue AS meteo_moyenne,
                   (y2 - y1) / NULLIF((x2 - x1), 0) AS conso_par_jour,
                   (y2 - y1) AS conso,
                   rawdata.id_releve id_releve,
                   meteodata.id_variable id_variable,
                   meteodata.id_compteur id_compteur
            FROM   rawdata
                   LEFT OUTER JOIN meteodata
                     ON rawdata.id_releve = meteodata.id_releve
            ORDER BY x2)
    SELECT periode,
           meteo_moyenne,
           conso_par_jour,
           consodata.id_variable id_variable,
           consodata.id_releve id_releve,
           id_compteur -- 1104 rows in 1.51s, 116 rows in 1.34s
    FROM   consodata
           LEFT OUTER JOIN diagnostic2
             ON consodata.id_releve = diagnostic2.id_releve
             AND consodata.id_variable = diagnostic2.id_variable;

  • Please help with this slow internet

    Can someone please help me with this slow internet. I have been looking on this forum for a while and have tried about everything I can do. I bought a new macbook, a new airport extreme base station, and have high speed internet. I can connect with a wire and it works great but wirelessly is slower than dial up. I am also not very good with computers so I am not sure how to do a lot of the things that many people say to do. I have comcast internet. If you need anymore information I will do my best to give it. Please help me fix this, remember it is the holiday season be a giver.
    Thanks in advance for any help you can give.
    Aaron

    I believe there are several reasons for Leopard's networking issues.
    I've heard it's worth a try to *turn off IPv6 in the OS network settings and your router* (if such an option exists in your router). IPv6 is the new addressing protocol which many consider to be overkill, seeing as it allows for approximately as many addresses as there are square centimeters of surface area on planet Earth (according to Wikipedia). It's also known to cause issues with Vista, which leads me to believe that the protocol is fundamentally flawed in some way.
    Just a note, turning off IPv6 in the OS is easy, simply go to *System Preferences* > Network > select the *network type* you're using (i.e. Wi-fi, ethernet, FireWire). Then click the Advanced... button, go to the TCP/IP tab, and say *Configure IPv6: Off*.
    Upgrading your router's firmware is worth a try, although such updates should only be performed through the ethernet connection, not over Wi-Fi (otherwise you could risk turning your router into a giant paperweight). You should also take note of your router settings prior to the firmware upgrade, because they will probably be reset with the upgrade.
    Check your *Activity Monitor* in Applications under Utilities. Right-click (or control-click) on the *Activity Monitor* icon and tell the *Dock Icon* to *Show CPU Usage*. Keep an eye on the CPU usage in the dock and if it goes higher than expected, click on the icon and tell the window to *Show Active Processes*, and/or organize the processes by order of CPU usage.
    Leopard doesn't have "nice" processes anymore and I find that some processes that like to use the network prevent other processes from using the network simultaneously. I think a lot of the network issues people are having are due to *Quick Look*, mdworker, and mds. These processes seem to like to go out on the network and make notes about every server available, however there doesn't seem to be any way to make these processes "nice" or kill them permanently without losing valuable system functions. It's interesting, at least, to see the probable cause of some of these networking problems, even if we can't fix them.
    By now, I'm sure I sound like I'm babbling, but I hope at least some of this helps somebody out there.

  • Synchronisation with a slower external signal

    Hello,
    I would synchronize 1 KHz continuous acquisition with an slower external clock. For example, I have a 100 or 200 Hz external clock and on each clock signal, I would read the acquisition buffer.
    On which pin of the DAQ board could I connect the external code ?
    Which function could I use on LabVIEW to synchronise the application with the external clock ?
    Thanks for your input
    Hubert Robitaille

    Hello;
    I don't know if I got your application need correctly by your description. By my understanding you want to have multiple external signals clocking each channel of the DAQ board.
    If that is the case, it's not possible, since the DAQ board accepts only one Scan clock pulse train. One thing you can do is to use the fastest clock as the external scan clock, and then skip some points on the other channels so you can collect the datapoints that match each scan clock needed.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National Instruments

  • How do I download 9.5 to install on a Mac with a slow Internet connection?

    Prior to Mavericks and the latest iLife apps, I was able to download installers from Apple support to install on an eligible Mac that has a slow (and tolled by usage) Internet connection. The new App store downloads and installs in one step such that it only leaves behind the installed app (not the installer image). Suggestions?

    Welcome to Apple Support Communities
    Mac App Store applications don't need an installer. In the case of iLife applications, you can just transfer the iPhoto, iMovie or GarageBand application to another Mac by transferring the application from the Applications folder, and you will get the applications updated on your Mac.
    If you haven't got another Mac with a fast Internet connection, you can only download the iLife applications with the slow connection

  • Subquery Factoring and Materialized Hint

    WITH t AS
            (SELECT MAX (lDATE) tidate
               FROM rate_Master
              WHERE     Code = 'G'
                    AND orno > 0
                    AND TYPE = 'L'
                    AND lDATE <= ':entereddate')
    SELECT DECODE (:p1,  'B', RateB,  'S', RateS,  Rate)
      FROM rate_Master, t
    WHERE     Code = 'G'
           AND orno > 0
           AND TYPE = 'L'
           AND NVL (lDATE, SYSDATE) = tidate;In the given example the sub query returns just one row because of the aggregate function max. Making this in to a With clause will be of any benefit ? Also i presume/understand that the subquery factoring would be really useful only when we try to make a sub query which returns more rows in a with clause. Is my intrepration right?
    Secondly adding the /*+ Materialize */ hint to a With query is mandatory or the optimizer by itself will do it and make a temp table transformation. In my example i am forced to give the hint in the query. Please discuss and help
    Thanks in advance.

    ramarun wrote:
    WITH t AS
    (SELECT MAX (lDATE) tidate
    FROM rate_Master
    WHERE     Code = 'G'
    AND orno > 0
    AND TYPE = 'L'
    AND lDATE <= ':entereddate')
    SELECT DECODE (:p1,  'B', RateB,  'S', RateS,  Rate)
    FROM rate_Master, t
    WHERE     Code = 'G'
    AND orno > 0
    AND TYPE = 'L'
    AND NVL (lDATE, SYSDATE) = tidate;In the given example the sub query returns just one row because of the aggregate function max. Making this in to a With clause will be of any benefit ? Also i presume/understand that the subquery factoring would be really useful only when we try to make a sub query which returns more rows in a with clause. Is my intrepration right?I am not aware of any performance Benefit due to use of With clause. IMO, It eases the job to write a Subquery multiple times in a query.
    The solution you adopted has to hit the cache twice and hence do not look very performant. I will advise you to opt for Analytic functions (like the suggestion I provided in another thread). If the solution does not yeild correct results, then provide with a Script that we can replicate (Create table, Sample Insert statement and the expected output).
    select decode(:p1, 'B', RateB, 'S', RateS, Rate)
       from (
                select RateB, RateS, Rate, NVL(ldate, sysdate) ldate, dense_rank() over (order by case when NVL(lDATE, SYSDATE) <= ':entereddate' then NVL(lDATE, SYSDATE) else to_date('01/01/1970', 'DD/MM/YYYY' end DESC) rn
                  from rate_Master
               where Code = 'G'
                   and orno > 0
                   and type = 'L'
             ) a
      where a.rn = 1;>
    Secondly adding the /*+ Materialize */ hint to a With query is mandatory or the optimizer by itself will do it and make a temp table transformation. In my example i am forced to give the hint in the query. Please discuss and help
    Usage of Hints is only for Debugging purposes and is not meant to be used in production code. It is when you have to ascertain the reason for CBO choosing a plan that you do not expect it to take, you use hints to force your plan and find the cost and analyze it. Hence, I do not support the idea of Hints for production code.

  • Subquery factoring and DB Link

    Hello,
    2 node RAC
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - ProductionI have a query of the form..
    WITH temp as
                 (select col1, col2, col3 from LOCAL_TABLE)
               SELECT /*+ driving_site (remote1) */
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 null,
                 null
              from remote_view1@dblink remote1, -- Remote View over 2 dbs
                     remote_view2@dblink remote2  -- Remote View over 2 dbs
               where remote1.col1 in (select col1 from temp);This query used to work, but recently there has been a change in remote_view1 after which the query takes a long time to execute.
    The good performing query takes 2 secs, while the bad performing one takes about 8 minutes.
    However, if I remove the subquery factoring and include the query as a sub-query it works well.
               SELECT /*+ driving_site (remote1) */
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote1.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 remote2.col1,
                 null,
                 null
              from remote_view1@dblink remote1, -- Remote View over 2 dbs
                     remote_view2@dblink remote2  -- Remote View over 2 dbs
               where remote1.col1 in  (select col1, col2, col3 from LOCAL_TABLE);I tried to check the data from v$sql. I observed that;
    v$sql.remote = 'Y' - good performance
    v$sql.remote = 'N' - bad performance
    Has anyone faced this situation ?
    Rgds,
    Gokul

    Am I right in assuming that queries executed entirely on remote db don't have plans stored in v$sql_planRight.
    SQL> select /*+ domtest */ 1 from dual@domtest;
             1
             1
    SQL> select * from table(dbms_xplan.display_cursor);
    PLAN_TABLE_OUTPUT
    SQL_ID  9d51rf84zvt0s, child number 0
    select /*+ domtest */ 1 from dual@domtest
    NOTE: cannot fetch plan for SQL_ID: 9d51rf84zvt0s, CHILD_NUMBER: 0
          Please verify value of SQL_ID and CHILD_NUMBER;
          It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    8 rows selected.
    SQL> select sql_id, remote, sql_text from v$sql where sql_id = '9d51rf84zvt0s';
    SQL_ID        R SQL_TEXT
    9d51rf84zvt0s Y select /*+ domtest */ 1 from dual@domtest
    SQL> select * from v$sql_plan where sql_id = '9d51rf84zvt0s';
    no rows selected
    SQL> select /*+ domtest */ 1 from dual@domtest t, dual;
             1
             1
    Elapsed: 00:00:00.00
    SQL> select * from table(dbms_xplan.display_cursor);
    PLAN_TABLE_OUTPUT
    SQL_ID  d0m08znks4yak, child number 0
    select /*+ domtest */ 1 from dual@domtest t, dual
    Plan hash value: 3754369022
    | Id  | Operation            | Name | Rows  | Cost (%CPU)| Time     | Inst   |IN-OUT|
    |   0 | SELECT STATEMENT     |      |       |     4 (100)|          |        |      |
    |   1 |  MERGE JOIN CARTESIAN|      |     1 |     4   (0)| 00:00:01 |        |      |
    |   2 |   REMOTE             | DUAL |     1 |     2   (0)| 00:00:01 | DOMTE~ | R->S |
    |   3 |   BUFFER SORT        |      |     1 |     2   (0)| 00:00:01 |        |      |
    |   4 |    FAST DUAL         |      |     1 |     2   (0)| 00:00:01 |        |      |
    Remote SQL Information (identified by operation id):
       2 - SELECT 0 FROM "DUAL" "T" (accessing 'DOMTEST' )
    22 rows selected.
    Elapsed: 00:00:00.04
    SQL> select sql_id, remote, sql_text from v$sql where sql_id = 'd0m08znks4yak';
    SQL_ID        R SQL_TEXT
    d0m08znks4yak N select /*+ domtest */ 1 from dual@domtest t, dua
    SQL> select /*+ driving_site(t) */ 1 from dual@domtest t, dual;
             1
             1
    Elapsed: 00:00:00.00
    SQL> select * from table(dbms_xplan.display_cursor);
    PLAN_TABLE_OUTPUT
    SQL_ID  741u736nrk6dx, child number 0
    select /*+ driving_site(t) */ 1 from dual@domtest t, dual
    NOTE: cannot fetch plan for SQL_ID: 741u736nrk6dx, CHILD_NUMBER: 0
          Please verify value of SQL_ID and CHILD_NUMBER;
          It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    8 rows selected.
    Elapsed: 00:00:00.01
    SQL> select sql_id, remote, sql_text from v$sql where sql_id = '741u736nrk6dx';
    SQL_ID        R SQL_TEXT
    741u736nrk6dx Y select /*+ driving_site(t) */ 1 from dual@domtest
                    t, dual
    Elapsed: 00:00:00.00
    SQL>
    SQL> select * from v$sql_plan where sql_id = '741u736nrk6dx';
    no rows selected
    Elapsed: 00:00:00.01
    SQL> Edited by: Dom Brooks on Aug 21, 2012 1:05 PM

  • Recursive subquery factoring datatypes?

    Hi all,
    using 11.2.0.2.0
    just mucking around with Recursive Subquery Factoring, trying to get my head around it.
    I can do this fine:
    SQL> with numlist (num) AS (SELECT 1 num
      2                          from dual
      3                          UNION ALL
      4                          SELECT numlist.num + 1
      5                            FROM numlist
      6                          where numlist.num < 10)
      7  SELECT *
      8    from numlist;
           NUM
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.but not with dates:
    SQL> WITH datelist (dte) AS (SELECT to_date('01-01-2011','dd-mm-yyyy') Dte
      2                   FROM dual
      3                 UNION ALL
      4                 SELECT datelist.dte + 1
      5                   FROM datelist
      6                  WHERE datelist.dte < trunc(SYSDATE))
      7  select *
      8    from datelist;
                   SELECT datelist.dte + 1
    ERROR at line 4:
    ORA-01790: expression must have same datatype as corresponding expressionI'm not sure what I need to do.....
    I'm sure it's a fairly straightforward

    Hemant K Chitale wrote:
    I don't have an 11.2.0 environment to test this.
    Try with a CAST at line 4 ? CAST X.DTE to a Date ?
    Hemant K Chitaleahh, that's a little bit better.... it seems a little bit funky though:
    15:38:58 SQL> WITH x (dte) AS (SELECT cast (to_date('01-01-2011','dd-mm-yyyy') as date) Dte
    15:39:02   2                   FROM dual
    15:39:02   3                 UNION ALL
    15:39:02   4                 SELECT cast(x.dte + 1 as date)
    15:39:02   5                   FROM x
    15:39:02   6                  WHERE x.dte < to_date('01-02-2011','dd-mm-yyyy'))
    15:39:02   7  select *
    15:39:02   8    from x;
    DTE
    01-JAN-11
    31-DEC-10
    30-DEC-10
    29-DEC-10
    28-DEC-10
    27-DEC-10
    26-DEC-10
    25-DEC-10
    24-DEC-10
    23-DEC-10
    22-DEC-10
    21-DEC-10
    20-DEC-10
    19-DEC-10
    18-DEC-10
    17-DEC-10
    16-DEC-10
    15-DEC-10
    14-DEC-10
    13-DEC-10
    12-DEC-10
    11-DEC-10
    10-DEC-10
    09-DEC-10
    08-DEC-10
    07-DEC-10
    06-DEC-10
    05-DEC-10
    04-DEC-10
    03-DEC-10
    02-DEC-10
    01-DEC-10
    30-NOV-10
    29-NOV-10
    28-NOV-10
    27-NOV-10
    26-NOV-10
    25-NOV-10
    24-NOV-10
    23-NOV-10
    22-NOV-10
    21-NOV-10
    20-NOV-10
    ...looks like it's going backwards.
    if I cast it like the below, it only gives me one record...
    15:39:03 SQL> WITH x (dte) AS (SELECT cast (to_date('01-01-2011','dd-mm-yyyy') as date) Dte
    15:40:52   2                   FROM dual
    15:40:52   3                 UNION ALL
    15:40:52   4                 SELECT cast(x.dte as date) + 1
    15:40:52   5                   FROM x
    15:40:52   6                  WHERE x.dte < to_date('01-02-2011','dd-mm-yyyy'))
    15:40:52   7  select *
    15:40:52   8    from x;
    DTE
    01-JAN-11
    1 row selected.This is bizarre....

Maybe you are looking for

  • Does deleting paragraph styles affect documents which used a deleted style?

    Assume you have a web page or site made with paragraph styles. You start a new page in that site but decide to delete a bunch of paragraph styles which you  no longer want The style should be in the html of the earlier documents and deleting the styl

  • Using Multi Mode in Omnisphere without "maxing" out my Mac

    Hi, I use Omnisphere a lot when I am creating multiple keyboard parts for tracks I am producing/session-ing on. But because I usually use about 6 different omnisphere parts in a track it really puts the pressure on my Mac and decreases performance. I

  • Trex 7.0 and ISA 5.0 Config guides

    Hi Can some tell me where to get Trex 7.0 and ISA 5.0 Config guides. I see significant changes here from Trex 6.1 ans ISA 4.0. Thanks in advance, Biren Bugati

  • NO ONE CAN DOWNLOAD ORACLE 10G EXPRESS FOR LIKE 3 DAYS!

    NO ONE CAN DOWNLOAD ORACLE 10 G EXPRESS LOGIN ERROR NOT ON USERS END! WERE CIS STUDENTS NOT IDIOTS, WE KNOW HOW TO LOG IN AND OUT AND ENABLE COOKIES. WE USED EVERY BROWSER. LEASE FIX YOUR WEBSITE. NEED SOFTWARE FOR CLASS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Finding long running queries inside procedure

    Hi All, Without using trace file or not modifying the existing procedure, is there any way to find out the query which is taking longer time (say out of 20) inside oracle procedure? Thanks in Advance, Geetha