Query tuning for query using connect by prior
I have written following query to fetch the data. The query is written in this format because there are multiple rows, which make one recrd and we need to bring that record into one row.
For one CAT(commented here), this query takes around 4 minutes and fetches 6900 records but when it runs for 3 CAT, it takes 17 mins.
I want to tune this as this has to run for 350 CAT values.
It is doing FTS on the main table. I tried to use different hints like PARALLEL, APPEND (in insert) but nothing worked.
The cost of the query is 51.
Any help/suggestions will be appreciated.
SELECT DISTINCT MIN(SEQ) SEQ,
PT, APP, IT, LR, QT,CD, M_A_FLAG,
STRAGG(REM) REM, -- aggregates the data from different columns to one which is parent
CAT
FROM (WITH R AS (SELECT CAT, SEQ, PT, M_A_FLAG, IT, LR,QT,CD, REM, APP
FROM table1
WHERE REC = '36' AND M_A_FLAG = '1'
--AND CAT = '11113')
SELECT CAT, SEQ,
CONNECT_BY_ROOT PT AS PT,
CONNECT_BY_ROOT APP AS APPL,
M_A_FLAG,
CONNECT_BY_ROOT IT AS IT,
CONNECT_BY_ROOT LR AS LR,
CONNECT_BY_ROOT QT AS QT,
CONNECT_BY_ROOT CD AS CD,
REM
FROM R A
START WITH PT IS NOT NULL
CONNECT BY PRIOR SEQ + 1 = SEQ
AND PRIOR CAT = CAT
AND PT IS NULL)
GROUP BY PT, APP, IT,LR, QT, CD, M_A_FLAG, CAT
ORDER BY SEQ;
Thanks.
Edited by: user2544469 on Feb 11, 2011 1:12 AM
The following threads detail the approach and information required.
Please gather relevant info and post back.
How to post a SQL tuning request - HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long - When your query takes too long ...
Similar Messages
-
OWB - possible to use connect by prior in mappings
Hi,
We get data supplied in hierarchical table and like to populate column on downstream table with level in hierarchy (parent, child or grandchild).
In sql can use connect by prior.
Is it possible to use this in mapping?
ThanksCheck this:
https://blogs.oracle.com/warehousebuilder/entry/connect_by_in_owb_10gr2_hierar -
Problem Creating a query for a hierarchical tree. [using connect by prior]
Hi all,
I have 2 tables.
box (box_id, box_name)
item(item_id, item_name, box_id)
In a box there are several items.
I want to create a hierachical tree to display items that are present in each box.
LIKE:
|---BOX1
| |----ITEM 1
| |----ITEM 2
|
|---BOX2
| |----ITEM 1
| |----ITEM 2
Currently i am trying this query:
SELECT -1 state, box_name, 'icon' icon, box_id val
from box b, item i;
I don't know what value to put for level, i don't know how to code the 'connect by prior' part.
Could you please advise me?
Michaël.
PS. Then i will eventually use this query in forms builder.Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*" - so only for issues with the SQL Developer tool. Please post these questions under the dedicated SQL And PL/SQL forum.
Regards,
K. -
Hierarchical query with out using Connect by prior
Hi Guys,
I am supporting a product which is enterprise based and only allowd to write queries which are ANSII standard.
I have an requirement like If I provide the child I need to know all the parents till highest level.
My table structure is like below
Table_name : Org_unit
Columns are
Org_unit_id name desc parent_org_unit_id
I wil pass the org_unit id and want to list all the parents of the chile org_unit_id and it has to be accomplished without using connec by prior.
Please suggest me some ideas and aprroches
I am using Orcle 11g versionHi,
960593 wrote:
Hi Guys,
I am supporting a product which is enterprise based and only allowd to write queries which are ANSII standard.
I have an requirement like If I provide the child I need to know all the parents till highest level.
My table structure is like below
Table_name : Org_unit
Columns are
Org_unit_id name desc parent_org_unit_id
I wil pass the org_unit id and want to list all the parents of the chile org_unit_id and it has to be accomplished without using connec by prior.
Please suggest me some ideas and aprroches
I am using Orcle 11g version
The data model you posted (org_unit_id as primary key, parent_org_unit_id as foreign key to the same table for the parent, when there is a parent) is called the Adjacency Model because it keeps track of which nodes are adjacent (or next to) each other.
I'm familiar with 2 other ways to model hierarchies: the Nested Sets Model, and what I call the Lineage Model. I'll show how to find a given node's ancestors (in hierarchical order) in each model. Neither the Nested Sets nor the Lineage Model requires CONNECT BY or recursive WITH clauses to work.
The following table contains all the columns necessary for using each of these 3 models:
EMPNO MGR ENAME LINEAGE NS_LOW NS_HIGH
7839 KING /7839/ 1 28
7698 7839 BLAKE /7839/7698/ 2 13
7499 7698 ALLEN /7839/7698/7499/ 3 4
7900 7698 JAMES /7839/7698/7900/ 5 6
7654 7698 MARTIN /7839/7698/7654/ 7 8
7844 7698 TURNER /7839/7698/7844/ 9 10
7521 7698 WARD /7839/7698/7521/ 11 12
7782 7839 CLARK /7839/7782/ 14 17
7934 7782 MILLER /7839/7782/7934/ 15 16
7566 7839 JONES /7839/7566/ 18 27
7902 7566 FORD /7839/7566/7902/ 19 22
7369 7902 SMITH /7839/7566/7902/7369/ 20 21
7788 7566 SCOTT /7839/7566/7788/ 23 26
7876 7788 ADAMS /7839/7566/7788/7876/ 24 25
The Lineage Model keeps track of all of a given nodes ancestors, so if all you need to find are the primary keys of a given node, it's really trivial: it's all in the lineage column. If you want to find more information about those ancestors, then you can do a self-join, like this:
SELECT a.empno, a.ename, a.lineage
FROM emp a
JOIN emp d ON d.lineage LIKE '%/' || a.empno || '/%'
WHERE d.ename IN ('ADAMS')
ORDER BY d.ename
, a.lineage
Output:
EMPNO ENAME LINEAGE
7839 KING /7839/
7566 JONES /7839/7566/
7788 SCOTT /7839/7566/7788/
7876 ADAMS /7839/7566/7788/7876/
The Nested Sets model is harder to understand.
Imagine everyone in the hierarchy standing on a wide staircase, as if for a group picture; everyone on the same level standing on the same step. Everyone is holding up an umbrella that is wide enough to cover himself and all the people who are under him in the hierarchy. The people with no underlings have small umbrellas, denoted like this "<-SMITH->", and peole that manage others have bigger umbrellas, like this: <-------- JONES -------->. So the group picture might look like this:
<-------------------------------------------- KING --------------------------------------------->
<---------------------- BLAKE ---------------------> <-- CLARK --> <-------- JONES -------->
<-ALLEN-> <-JAMES-> <-MARTIN-> <-TURNER-> <-WARD-> <-MILLER-> <-- FORD--> <--SCOTT-->
<-SMITH-> <-ADAMS->
Each parent's umbrella covers all of his descendants (children, grandchildren, etc.), and nobody else.
Now draw vertical lines trom the edges of each umbrella downwards, and number those lines from left to right:
<-------------------------------------------- KING ------------------------------------------------>
| |
| <---------------------- BLAKE ---------------------> <-- CLARK -> <-------- JONES ----------> |
| | | | | | | |
| |<-ALLEN-> <-JAMES-> <-MARTIN-> <-TURNER-> <-WARD->| |<-MILLER->| |<-- FORD--> <--SCOTT---> | |
| || | | | | | | | | || || || || | | | | |
| || | | | | | | | | || || || ||<-SMITH->| |<-ADAMS-> | | |
| || | | | | | | | | || || || ||| || || | | | |
1 1 11 11 11 112 22 22 2 2 2 2
1 23 4 5 6 7 8 9 0 1 23 45 67 890 12 34 5 6 7 8
The numbers corresponding to the left arnd right edges of each umbrella are what I called ns_low and ns_high in the table. Each employyes ns_low and ns_high numbers will be inside the range of each of his ancestors ns_low and ns_high.
To find the ancestors of a given node in the nested set model you can do this:
SELECT a.empno, a.ename, a.ns_low, a.ns_high
FROM emp a
JOIN emp d ON d.ns_low BETWEEN a.ns_low
AND a.ns_high
WHERE d.ename IN ('ADAMS')
ORDER BY d.ename
, a.ns_low
Both the Lineage and Nested Sets models are good for tree structures only, whereas the Adjacency Model can handle other kinds of graphs, including graphs with loops.
Both the Lineage and Nested Sets models can be very difficult to maintain if the hierarchy is re-organized.
I'd like to repeat some of the warnings that others have made. You could write separate code for each system (Oracle, SQL Server, ...) that you want to run in, and the code for each system will be more or less different. You're looking for some code that will get the same results in all systems. That code will be more complicated that the most complicated of the single-system versions, and it will be sloweer than the slwoest of the single-system versions. You're giving up a lot of functionality, and probably also ease of maintenance, by writing code that has to work on multiple systems without changes.
Here's how I created the emp table shown above from scott.emp:
CREATE TABLE emp
AS
WITH connect_by_results AS
SELECT empno, mgr, ename
, LEVEL AS lvl
, ROWNUM AS r_num
, SYS_CONNECT_BY_PATH (empno, '/') || '/' AS lineage
FROM scott.emp
START WITH mgr IS NULL
CONNECT BY mgr = PRIOR empno
ORDER SIBLINGS BY ename
SELECT empno, mgr, ename, lineage
, (2 * r_num) - lvl AS ns_low
, (2 * r_num) + ( 2 * (
SELECT COUNT (*)
FROM connect_by_results
WHERE lineage LIKE '%/' || cbr.empno || '/%'
- (lvl + 1) AS ns_high
FROM connect_by_results cbr
This relies on the fact that the hierarchy in scott.emp has only one root (that is, a node with no parent). Computing the Nested Sets numbers is a little more complicated if you can have multiple roots. -
APEX 'crawling' whilst executing a query using CONNECT BY
Hi Folks.
Anyone seen this behaviour before?
I can run this SQL (with the appropriate page item values substitued) in PL/SQL developer and I get the result in less than 0.094 seconds with a COST of 13
SELECT NULL LINK
,a.data_points
,5000 forecast_value
FROM
(SELECT to_char(trunc(add_months((SELECT iag.agreement_start_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID)
,LEVEL - 1)
,'mm')
,'MON-RR') data_points
FROM dual
CONNECT BY LEVEL <=
trunc(months_between((SELECT iag.agreement_end_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID)
,(SELECT iag.agreement_start_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID)))
MINUS
SELECT pkg_ngc_utilities.get_long_traffic_month(imps.traffic_period_id)
FROM iot_mfs_plus_summary imps
WHERE imps.client_master_entity_id = :P317_CLIENT_MASTER_ENTITY_ID
AND imps.home_master_entity_id IN
(SELECT ipy.master_entity_id
FROM iot_party ipy
WHERE ipy.iot_agreement_id = :P317_IOT_REBATE_AGREEMENT_ID
AND ipy.client_side = 0) -- Roaming Partner
AND imps.visited_master_entity_id = imps.client_master_entity_id
AND pkg_ngc_utilities.get_long_traffic_month(imps.traffic_period_id) IN
(SELECT to_char(trunc(add_months((SELECT iag.agreement_start_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID)
,LEVEL - 1)
,'mm')
,'MON-RR') data_points
FROM dual
CONNECT BY LEVEL <= trunc(months_between ((SELECT iag.agreement_end_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID) ,
(SELECT iag.agreement_start_date
FROM iot_agreement iag
WHERE iag.iot_agreement_id =
:P317_IOT_REBATE_AGREEMENT_ID)
)))) a
ORDER BY to_date(a.data_points, 'MON-RR')If I use the same query in a Flash Chart the page still only takes a few seconds to display but the chart takes over a minute to display. APEX ADMIN shows the page being served in 2 - 3 seconds.
If I drop the chart and drop the query into a simple report region, the entire page takes over a minute to display.
Has anyone experienced anything similar?
This is the first time I have used CONNECT BY LEVEL in my SQL so that is my main suspect. But please remember, in SQL/Developer the query executes very quickly indeed.
Many thanks
Kind regards
Simon GaddHi Simon,
I had something similar. When my code ran is SQL is took seconds, but took minutes in an ApEx page. There seems to the something strange with the way ApEx and/or the optimizer execute code via ApEx pages.
I gave my code to one of my tuning experts and they added a simple rule to force index use:
select /*+RULE index(r AMS_REQUESTS_IDX4) */
r.requester_name,
r.ams_type_code_name,
d.display_date
from
(select TO_DATE(:P23_CALENDAR_DATE,'YYYYMMDD')-100+rownum display_date from all_objects where rownum < 300) d,
ams_requests_v r
where
trunc(d.display_date) between trunc(r.start_date) and trunc(r.end_date)
and r.approval_status != 'R'
and to_char(d.display_date,'DY') NOT IN ('SAT','SUN')
and d.display_date not in (select trunc(closure_date) from ams_closures)
and (nvl(r.restricted_view_flag,'N') = 'N' or trunc(r.end_date) >= trunc(sysdate))
and r.department_id in ( select
d.department_id
from
ams_departments d
connect by ( PRIOR DEPARTMENT_ID = PARENT_DEPARTMENT_ID)
start with department_id = (
select
department_id
from
ams_departments
where
nvl(terminating_dept_flag,'N') = 'Y'
and level = (select
min(level)
from
ams_departments
where
nvl(terminating_dept_flag,'N') = 'Y'
connect by department_id = prior parent_department_id
start with department_id = :P0_DEPARTMENT_ID)
connect by department_id = prior parent_department_id
start with department_id = :P0_DEPARTMENT_ID))
UNION
select /*+RULE index(r AMS_REQUESTS_IDX4) */
r.requester_name,
r.ams_type_code_name,
d.display_date
from
(select TO_DATE(:P23_CALENDAR_DATE,'YYYYMMDD')-100+rownum display_date from all_objects where rownum < 300) d,
ams_requests_v r
where
trunc(d.display_date) between trunc(r.start_date) and trunc(r.end_date)
and r.approval_status != 'R'
and to_char(d.display_date,'DY') NOT IN ('SAT','SUN')
and d.display_date not in (select trunc(closure_date) from ams_closures)
and nvl(r.restricted_view_flag,'N') = 'Y'
and r.department_id in ( select distinct
d.department_id
from
ams_departments d
connect by ( PRIOR DEPARTMENT_ID = PARENT_DEPARTMENT_ID)
start with department_id in (
select
department_id
from
ams_departments_v
where
:P0_PERSON_ID in (manager_id, deputy_id,administrator_id)))
UNION
select
NULL requester_name,
t.name ams_type_code_name,
trunc(c.closure_date) display_date
from
ams_closures c,
ams_closure_type_codes_v t
where
c.AMS_CLOSURE_TYPE_CODE = t.AMS_CLOSURE_TYPE_CODE
order by 3,1It might be worth you trying something similar.
best regards,
Martin -
Hi guys,
We have this below table with three coloumns
Id Value Parentid
1234 6
1235 7 1234
1239 8 1235
1338 9 1337
1237 8 1239 in this table if i give 1237 in the where condition or any kind of input... query should return 6,7,8,8
it should find out the value of the parentid and get it's value and travers untill the parentid is null
please help me in writing the above query
Edited by: Depakjan on Apr 20, 2011 10:51 AM
Edited by: Depakjan on Apr 20, 2011 10:52 AMwith Table1 as (
select 1234 Id , 6 value, null Parentid from dual union all
select 1235, 7, 1234 from dual union all
select 1239, 8, 1235 from dual union all
select 1338, 9, 1337 from dual union all
select 1237, 8, 1239 from dual
select value
from table1
start with id = 1237
connect by prior parentid=id -
How to get the root node for a child using connect by prior
Hi,
I searched at many places to do this but not able to get the exact o/p sp posting my question here.
I have a table with parent_id and child_id columns. The levels of this parent_child can be many but my aim is to find the ultimate parent ( dont know the right term)
like if I have a child_node= xyz and its parent= pqr and its parents=lmn which might be ultimate parent which doesnt have any further parent.
So if i start with child_code= "xyz" then i should get the parent as "lmn" and not the immediate parent "pqr".
Please help.
Thanks,
AashishTo find the Parent on emp table:
select empno,ename,level
from emp
where level=3
start with empno=7934
connect by empno= prior mgrTo find the Child on emp table:
select empno,ename,level
from emp
where level=1
start with empno=7934
connect by prior empno= mgrBut you need to know the level or position to specify the level of parent or child. But there are some other possible options available if we can know the requirement properly.
Edited by: Vasista on Jan 11, 2011 2:27 AM
Edited by: Vasista on Jan 11, 2011 2:30 AM -
To remove duplicate data using connect by prior
Hi ,
I want to details of the employee whom reporting to without duplication .
In table data,one employee reporting to two employees.so that reporting to process is coming two times.
Query:
SELECT lpad(' ', (level - 1) * 2) || EMPLOYEE_NAME as EMP_NAME,SUP_BU AS BU_CODE,SUP_REP_BU,EMP_NO,EMPLOYEE_NAME,LEVEL AS THE_LEVEL
FROM ATTD_REPORT_TO_VW
WHERE EMP_NO IS NOT NULL
CONNECT BY PRIOR SUP_BU = SUP_REP_BU
START WITH SUP_BU = :p_bu
BUT i get the duplicate data,SUPPOSE i remove the duplication using distinct keyword ,the order of hierarchical is going wrong.
Pls provide the solution.
Thanks ,
Maranplz ask this question in seperate SQL/PLSQL forum and also provide more information with sample data
-
SQL query using connect by clause
Hi,
I have table:
SQL> col id for 999
SQL> col code for a30
SQL> select id,code from t1;
ID CODE
704 ,2,3,7,8,
707 ,15,12,17,18,
742 ,23,25,27,28,
5 ,53,65,67,58,
4 rows selected.---
When I run query:
select id,
substr(code,instr(code,chr(44),1,level)+1,instr(code,chr(44),1,level+1)-instr(code,chr(44),1,level)-1) code
from(
select id,
code,
length(code) - length(replace(code,',',''))-1 len
from t1
where id=5)
connect by level <= len;
ID CODE
5 53
5 65
5 67
5 58
4 rows selected.How to modify my query to get this output:
ID CODE
5 53
5 65
5 67
5 58
704 2
704 3
704 7
704 8
707 15
707 12
707 17
707 18
742 23
742 25
742 27
742 28What is the best way to get this output?
My db:
SQL> select * from v$version;
BANNER
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for Solaris: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
5 rows selected.Thanks for answers!
Regards,
MarkoHi,
Generate a separate "counter table" that has the numbers 1, 2, 3, ... , x, where x is the greatest number you'll ever need.
Join to this table, using a join condition that gets the exact numbers you need for each row.
Use the number from the counter table where you are currently using LEVEL.
That is:
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= ( SELECT MAX ( LENGTH (code)
- LENGTH (REPLACE (code, ','))
FROM t1
) - 1
select id,
substr(code,instr(code,chr(44),1,n)+1,instr(code,chr(44),1,n+1)-instr(code,chr(44),1,n)-1) code
FROM t1
JOIN cntr ON cntr.n <= LENGTH (code) - LENGTH (REPLACE (code, ','))
;If you're using Oracle 10 (or higher) regular expressions would simplify this a lot. -
Recursive joins / how to define query using connect by clause
Hi,
I have a table A have 1-1 reltionship with table Employee
Structure of table is as follows
Table A
id name employee_id
100 aa 1
200 bb 2
300 cc 3
400 dd 4
500 ee 5
Table Employee
id parent_id
1 null
2 1
3 2
4 3
5 1
6 1
I want to get all records from A table whose employee_id is equal to 2 or (recursive)decendants/child of employee with id 2 (i.e. employee with id 2,3,4 )
i.e I want recursively join where in I get records from table A as
id name employee_id
200 bb 2
300 cc 3 (because it is child of employee with id 2)
400 dd 4 (becaue it is child of employee with id 3 which is child of 2)
I know we can use In clause , but it will be performance wise not good.
Can we do it in Toplink without using IN clause?
Oracle has connect by clause, but other database might not have this caluse. So how can write a toplink query which can run on any database.
Any help is highly appreciated.
Thanks a lot.You can use TopLink's Hierarchical Query support but this only works with Oracle DB as it relies on the database to perform the query.
--Shaun -
Reg : Hierarchical Query(Using Connect By)
Hi all,
I got the result with the hierarchical query as :
*/qxxh*
*/qxxh/jxobcbg*
*/qxxh/jxobcbg/n00wcp4*
*/qxxh/jxobcbg/n00wcp4/x000263*
*/qxxh/jxobcbg/n00wcp4/x000263/p0263*
*/qxxh/jxxocbg*
*/qxxh/jxxocbg/n00voc1*
*/qxxh/jxxocbg/n00voc1/x000589*
*/qxxh/jxxocbg/n00voc1/x000589/p0589*
*/qxxh/jxuwxxh*
*/qxxh/jxuwxxh/n00xpxf*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl/x000522*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl/x000522/p0522*
Here I want to select only maximum path . Here I used "SYS_CONNECT_BY_PATH"
Please let meknow how to do this ?
Thanks in advance .
Edited by: udeffcv on Dec 9, 2009 10:03 PMudeffcv wrote:
Hi all,
I got the result with the hierarchical query as :
*/qxxh*
*/qxxh/jxobcbg*
*/qxxh/jxobcbg/n00wcp4*
*/qxxh/jxobcbg/n00wcp4/x000263*
*/qxxh/jxobcbg/n00wcp4/x000263/p0263*
*/qxxh/jxxocbg*
*/qxxh/jxxocbg/n00voc1*
*/qxxh/jxxocbg/n00voc1/x000589*
*/qxxh/jxxocbg/n00voc1/x000589/p0589*
*/qxxh/jxuwxxh*
*/qxxh/jxuwxxh/n00xpxf*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl/x000522*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl/x000522/p0522*
Here I want to select only maximum path . Here I used "SYS_CONNECT_BY_PATH"
Please let meknow how to do this ?
Thanks in advance .
Edited by: udeffcv on Dec 9, 2009 10:03 PMwhat do you mean by maximum path?? is it...
*/qxxh/jxobcbg/n00wcp4/x000263/p0263*
*/qxxh/jxxocbg/n00voc1/x000589/p0589*
*/qxxh/jxuwxxh/n00xpxf/m00bxpl/x000522/p0522*
is it child nodes??
then you might like to see
CONNECT_BY_ISLEAF pseudo column..example you can find it in below link
http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/pseudocolumns001.htm#sthref670
Ravi Kumar -
Hi,
We are writing some complex query using Connect by Prior in it.
When we execute this query on same version of database as that of our client, then the query is executing.
But when we execute this query at client's side then it raises error -
ORA-00600: internal error code, arguments: [kkqcbydrv:1] , [] , [] , [] , [] , [] , [] , []
After searching on metalink,
We could find two workarounds -
1. Use a /*+no_unnest*/ hint, but this may have perfomance implications.
2. alter session set "_optimizer_connect_by_cost_based"=false;
of which we cant use second workaround as this query is called from a application and not directly from oracle prompt.
We are working with the first workaround, but what is wondering us is that,
If same query can work well on our side then why is this query not performing in same way at client's side?
We are using same version of database, same amount of data is present in development and production databases.
Then what is causing this error only in priduction?
Any help in this regard is appreciated.
Thanks,
Av.You can use the second tip in a database login trigger. But if the metalink ORA-600 diagnostic tool can only give you those workarounds I suggest raising a SR to try and get the bug fixed.
It may be differing patch levels that cause the difference between the two sites, some subtle difference in temp tablespace, a corrupt block - impossible for us to say but maybe not for Oracle. -
How to use simple SQL instead of Connect By Prior
Currently, I am using "connect by prior" query in the application, but for reason I don�t want to use this connect by query so can any one please tell how does I get the same result by using SQL, I tried this by using procedure but unable to get the same result, specially LEVEL of the tree.
So please tell, how would I get the correct data.
Thanks in advance,
AMIT.Hi,
Whenever you have a question, it helps to post:
(1) The version of Oracle (and any other relevant software) you're using
(2) A little sample data (just enough to show what the problem is) from all the relevant tables
(3) The results you want from that data
(4) Your best attempt so far (formatted) I don't believe the unformated code you posted is what you're really running, since it has a syntax error ("... WHERE START WITH ..."). Please post code that really works with the sample data you posrted.
(5) The full error message (if any), including line number
Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
If you can present your problem using commonly available tables (for example, scott.emp, which contains a hierarchy), then you can omit (2).
Formatted tabular output is okay for (3). Type these 6 characters
{code}
(small letters only, inside curly brackets) before and after the tabular text, to preserve spacing.
As Alex said, why don't you want to use CONNECT BY?
Are you getting the correct results now, but just looking for a different way of getting them?
Depending on your exact requirements, you could write a PLSQL function that mimics LEVEL. Don't expect it to be fast.
Nested Sets is a completely different way of modeling trees.
Some things are much easier with Nested Sets than they are using the Adjacency Model (the parent-child model that uses CONNECT BY).
But some things are much harder with Nested Sets, and LEVEL is one of them. -
Connect by prior problem with order by
Hi,
I and using connect by prior within a query on Oracle 8 and would like to order the results within the parent levels.
All the documentation that I have read shows that in Oracle 9i there is an option to say order siblings by which looks like what I need, but this does not work on Oracle 8.
Can anyone tell me how I can order the children within the parents without changing the tree structure?
I have also tried SYS_CONNECT_BY_PATH and I just get an error saying that it is an invalid column name,Karen, see here for a dicussion on how to order the siblings in a pre-9i environment:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:9212348049 -
In our application, we have a lot of 'trees' in our data (parent/child relationships within a table). We rely heavily on 'connect by prior' to search through the trees, to find for example values that are defined in one of the parents ('inheritance').
Lately however, we've been eliminating connect by priors wherever we can lately, because performance is dramatic. No matter what indexes we use, we keep getting full tablescans on large tables because of the connect by priors. Views with 2 connect by priors are deadly for performance.
What is a good way to optimize connect by priors?
As an example of why we use connect by prior, consider this:
table A
ID PARENT_ID NAME LENGTH
1 NULL root 10
2 1 child NULLWe consider record 2 'derived' from record 1, inheriting its length. The alternative for connect by prior is to populate the child length whenever the master length changes, and this is what we do in most situations now, but it's hell to keep track of this. If a record changes, you would still have to go down the tree to change all child lengths etc, so we rather use connect by prior.
Any ideas?Ivo, would you please post the table definition (if different than your example), the actual list of indexes, a sample query, and the explain plan for that query?
I use hierarchical queries extensively on tables with millions of rows. They work very well if all the pieces are in place. Let's see if we can get your queries humming...
Maybe you are looking for
-
I use (Mac OS X 10.6.6) and just upgraded to Firefox 4.0 and now some of the Content on my MSN.CA Homepage only has the Title but no content underneath. How can I Fix This?
-
Backup Oracle VMs using a direct attached tape library
Hello all, I'm in the process of getting a specification for a new Oracle VM host server which will run OEL VMs and host Oracle databases (10g and others), currently we're looking at getting an HP DL580 and a MSL6000 tape library using SAS connectors
-
Hi, I have created a shop game, which has a BankAccount class, Customer class and Shop class. When the program starts the Customer objects are passed to the Shop class and they buy objects depending on what they want (randomly generated) the numBread
-
Post Author: R32CA CA Forum: Analytics I see this subject mentioned before but don't see any resolutions......can anybody tell me why I would be getting a "Missing Prompts" error message when I try to create a dimension? One reply did say that syntax
-
I just purchased a HP touch screen. I am trying to import music from a jump drive. How do I do this??? Please help.