Query with order by & View/procedure
1)I have a query its getting joined with few tables and the base table contains 12 billion rows . my issue is when I execute the query with necessary parameter am getting the result in few seconds . but when I add an order by for any column am not getting the result even after 15 minuts.
The sort column is an indexed column and I have even tried with the primary column of the base table but no change .. is there any way to make it faster with order by ??
2)I have got a view which also getting joined with few high volume tables . when I call the view with required parameter am not getting the result even after 15 minutes.. but when I took out the query of the view and hardcode the value am getting the result in 3 seconds . so I just made it to a procedure that returns a cursor . now its working fine .. could you please explain me the reason for this ….??
Please help …
select * from
(select Rownum RowNO,Qr.* from
(select T1.c1,T2.C2,T3.c3 from TI,T2,T3
where < all required joins>
order by Ti.c)Qr
where RowNum <20 )
where RowNO >10 ;As said before:
Your view very likely prevented predicate pushing and by manually adding the predicate inside the query, you changed the semantics of the query.
Your view contains a rownum column. This prevents predicate pushing because the semantics of the query changes. An example to clarify:
SQL> explain plan
2 for
3 select *
4 from ( select empno
5 , ename
6 , sal
7 from emp
8 )
9 where empno = 7839
10 /
Uitleg is gegeven.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 4024650034
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 14 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 14 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | EMP_PK | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("EMPNO"=7839)
14 rijen zijn geselecteerd.
SQL> exec dbms_lock.sleep(1)
PL/SQL-procedure is geslaagd.
SQL> explain plan
2 for
3 select *
4 from ( select empno
5 , ename
6 , sal
7 from emp
8 where empno = 7839
9 )
10 /
Uitleg is gegeven.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 4024650034
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 14 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 14 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | EMP_PK | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("EMPNO"=7839)
14 rijen zijn geselecteerd.The previous two queries show that in this case the predicate "empno = 7839" can be pushed inside the view. Both queries are semantically the same.
However, when you add a rownum to your view definition, like you did, the predicates cannot be pushed inside the view:
SQL> exec dbms_lock.sleep(1)
PL/SQL-procedure is geslaagd.
SQL> explain plan
2 for
3 select *
4 from ( select empno
5 , ename
6 , sal
7 , rownum rowno
8 from emp
9 )
10 where empno = 7839
11 /
Uitleg is gegeven.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2077119879
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 14 | 644 | 3 (0)| 00:00:01 |
|* 1 | VIEW | | 14 | 644 | 3 (0)| 00:00:01 |
| 2 | COUNT | | | | | |
| 3 | TABLE ACCESS FULL| EMP | 14 | 196 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("EMPNO"=7839)
15 rijen zijn geselecteerd.
SQL> exec dbms_lock.sleep(1)
PL/SQL-procedure is geslaagd.
SQL> explain plan
2 for
3 select *
4 from ( select empno
5 , ename
6 , sal
7 , rownum rowno
8 from emp
9 where empno = 7839
10 )
11 /
Uitleg is gegeven.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1054641936
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 46 | 1 (0)| 00:00:01 |
| 1 | VIEW | | 1 | 46 | 1 (0)| 00:00:01 |
| 2 | COUNT | | | | | |
| 3 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 14 | 1 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | EMP_PK | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("EMPNO"=7839)
16 rijen zijn geselecteerd.Now the two queries are not the same anymore. If you wonder why, please look carefully at the query results of both:
SQL> select *
2 from ( select empno
3 , ename
4 , sal
5 , rownum rowno
6 from emp
7 )
8 where empno = 7839
9 /
EMPNO ENAME SAL ROWNO
7839 KING 5000 9
1 rij is geselecteerd.
SQL> select *
2 from ( select empno
3 , ename
4 , sal
5 , rownum rowno
6 from emp
7 where empno = 7839
8 )
9 /
EMPNO ENAME SAL ROWNO
7839 KING 5000 1
1 rij is geselecteerd.Regards,
Rob.
Similar Messages
-
Hi,
I found a query with order by clause in procedure which is taking long time.
Stats are upto date.
Total Rows :650000.
It is ordered by primary key column.
select * from table_name order by col1;
col1 is a primary key.No of cpu's used is 4.
can anyone suggest me a better solution to improve the performance of a query.
Is it better to use parallel hint for above scenario.
Any help really apprecaited.
Thanks in advance.Hi,
Thanks for ur immediate reply.
It doesn't have where clause.
below is the plan
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 619071987
| Id | Operation | Name | Rows | Bytes | Cos
| 0 | SELECT STATEMENT | | 671K| 255M| 125
| 1 | TABLE ACCESS BY INDEX ROWID| FULL_ITEM_FACILITIES | 671K| 255M| 125
| 2 | INDEX FULL SCAN | FIF_PK | 671K| |
9 rows selected
Executed in 0.094 secondsThanks in advance
Edited by: unique on Jun 22, 2009 8:26 AM -
Hi ,
I have created a sub query with order by on a column.( i have cutomized the IKM control append to put order by).I can see the order by condition.If i use this subquery(yellow interface) in main query(is also yellow interface) i can't see the order by condition
Subquery(Q-yellow interface):
select
PID,
START_TIME,
ACTION_TYPE_CODE
FROM
select DISTINCT
SERVICE_TRACKING_S.PID PID,
TO_TIMESTAMP(TO_CHAR(SERVICE_TRACKING_S.ACTION_TIME,'DD-MON-YY HH24:MI:SS'),'DD-MON-YY HH24:MI:SS') START_TIME,
SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
from KSTGDB.SERVICE_TRACKING_S SERVICE_TRACKING_S
where (1=1)
ORDER BY-----------------------------------------------
PID
,START_TIME ASC
ODI_GET_FROM
Main query(Q1--yellow interface):
select
PID,
START_TIME,
ACTION_TYPE_CODE,
RN,
RN_MAX
FROM (
select
Q.PID PID,
Q.START_TIME START_TIME,
CASE WHEN Q.START_TIME-LAG(Q.START_TIME,1,Q.START_TIME) OVER (PARTITION BY Q. PID ORDER BY Q.START_TIME)> numtodsinterval(75,'minute')
or Q.PID!=LAG(Q.PID,1,0) OVER (PARTITION BY Q.PID ORDER BY Q.START_TIME) THEN 1 ELSE Q.ACTION_TYPE_CODE END ACTION_TYPE_CODE,
ROW_NUMBER() OVER(PARTITION BY Q.PID ORDER BY Q.START_TIME) RN,
count(*) over (PARTITION BY Q.PID ORDER BY Q.START_TIME ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
RN_MAX
from (
select DISTINCT
SERVICE_TRACKING_S.PID PID, TO_TIMESTAMP(TO_CHAR(SERVICE_TRACKING_S.ACTION_TIME,'DD-MON-YY HH24:MI:SS'),'DD-MON-YY HH24:MI:SS') START_TIME, SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
from KSTGDB.SERVICE_TRACKING_S SERVICE_TRACKING_S
where (1=1)
----------------- i don't see order by here--------------------------------
) Q
where (1=1)
) ODI_GET_FROM
thanks in advance
KHi,
Add a new KM step with the SQL you want to use for the sub query and select the +"Use Current Command for Derived-Table sub-select statement"+ checkbox. This new step can be the last one of your IKM.
Basically, you can copy the select statement of the "Insert new rows" step.
Regards,
JeromeFr -
Improve performance of query with order by
Hello,
I have a query with a necessary "order by" which lasts 24 seconds. The same query without the "order by" lasts 1 second.
How can I improve the performance of the query with "order by"?
Thank you very much.
The query is:
select distinct CC.acceso,CC.ext_acceso,TIT.TITULO_SALIDA
from (((Ocurrencias CT01 inner join
palabras p0 on (CT01.cod_palabra = p0.cod_palabra and p0.palabra like 'VENEZUELA%' AND p0.campo = 'AUTOR')) INNER JOIN
CENTRAL CC ON (CT01.ACCESO = CC.ACCESO AND CT01.EXT_ACCESO = CC.EXT_ACCESO))) inner join
codtit ctt on (CC.acceso = ctt.acceso and CC.ext_acceso = ctt.ext_acceso) inner join
titulos tit on (ctt.cod_titulo = tit.cod_titulo and ctt.portada = '1')
where CC.nivel_reg <> 's'
ORDER BY 3 ASC;My guess is SQL Scratchpad is a GUI and is not returning all the rows but just the first screenful. Without any order by or distinct the database can start returning rows as soon as it finds the first one. With an order or distinct it needs to sort the rows so the first row can only be returned after the last row is retrieved.
Open a command line prompt and run
sqlplus
SQL> set timing on
SQL>And then run your queries.
If you still have a large discrepancy do this
SQL> set autotrace traceonly
SQL>And then run the queries and post the output. -
Query with order by taking 1 hr
Hi,
Query with order by taking 1 hr, without order by taking 9 seconds,
pls tell me ,wat will be the reason and how to tune.
Query:
SELECT
T17.CONFLICT_ID,
T17.LAST_UPD,
T17.CREATED,
T17.LAST_UPD_BY,
T17.CREATED_BY,
T17.MODIFICATION_NUM,
T17.ROW_ID,
T1.ACCNT_TYPE_CD,
T36.X_BRIDGESTATION,
T36.X_CTI_PIN,
T36.X_FLOOR,
T36.X_SEGMENT2,
T36.X_SEGMENT3,
T36.X_CONTACT_STATUS,
T36.X_DEALING_CODE,
T36.X_DELETE,
T36.X_DEPARTMENT,
T36.X_DIRECT_MKT,
T36.X_FASS_LAST_CONTACT_DATE,
T36.X_SEGMENT1,
T36.X_LAST_TRAINED_DATE,
T36.X_LEGAL_CONSENT,
T36.X_LOCAL_FST_NAME,
T36.X_LOCAL_LAST_NAME,
T36.X_PREF_LANG,
T36.X_PROD_BLEND,
T36.X_SALUTATION,
T36.X_BSC_SIDE,
T36.X_END_USR_ACT,
T36.X_PRIM_ASSET_CLASS,
T36.X_SEC_ASSET_CLASS,
T36.X_STATUS,
T36.X_LANGUAGE,
T36.X_SUPPRESS_SMS_FLG,
T36.X_TRAINING_ADDRESS,
T36.X_UPD_TYPE,
T36.X_XTRA_UPD,
T36.X_XTRA_ID,
T36.X_ESERVICE_USER,
T36.X_SALES_COMMENTS,
T36.PR_DEPT_OU_ID,
T1.INTEGRATION_ID,
T1.PRTNR_FLG,
T36.BIRTH_DT,
T36.CELL_PH_NUM,
T9.ATTRIB_07,
T5.LAST_UPD,
T36.EMAIL_ADDR,
T36.EMP_FLG,
T36.FAX_PH_NUM,
T36.FST_NAME,
T36.HOME_PH_NUM,
T36.JOB_TITLE,
T36.LAST_NAME,
T36.SEX_MF,
T36.PER_TITLE,
T36.MID_NAME,
T36.OWNER_PER_ID,
T17.NAME,
T36.PERSON_UID,
T36.PRIV_FLG,
T1.NAME,
T29.PR_ADDR_ID,
T36.PR_REP_DNRM_FLG,
T36.PR_REP_MANL_FLG,
T36.PR_REP_SYS_FLG,
T36.PR_MKT_SEG_ID,
T36.PR_GRP_OU_ID,
T36.PR_OPTY_ID,
T36.PR_PER_ADDR_ID,
T36.PR_PER_PAY_PRFL_ID,
T36.PR_POSTN_ID,
T36.PR_RESP_ID,
T19.OWN_INST_ID,
T19.INTEGRATION_ID,
T36.SOC_SECURITY_NUM,
T29.STATUS,
T36.SUPPRESS_CALL_FLG,
T36.SUPPRESS_MAIL_FLG,
T36.WORK_PH_NUM,
T36.BU_ID,
T36.PR_ALT_PH_NUM_ID,
T36.PR_EMAIL_ADDR_ID,
T36.PR_SYNC_USER_ID,
T18.SHARE_HOME_PH_FLG,
T36.PR_REGION_ID,
T36.NATIONALITY,
T36.CITIZENSHIP_CD,
T36.AGENT_FLG,
T36.MEMBER_FLG,
T13.PR_EMP_ID,
T36.PR_OU_ADDR_ID,
T33.PR_EMP_ID,
T13.PR_EMP_ID,
T21.LOGIN,
T26.LOGIN,
T25.PR_FAX_NUM_ID,
T36.PR_INDUST_ID,
T36.PR_NOTE_ID,
T1.PR_POSTN_ID,
T36.PR_PROD_LN_ID,
T25.PR_SMS_NUM_ID,
T36.PR_SECURITY_ID,
T6.NAME,
T36.MED_SPEC_ID,
T36.PR_STATE_LIC_ID,
T36.PR_TERR_ID,
T36.PROVIDER_FLG,
T36.CUST_SINCE_DT,
T34.ADDR,
T34.CITY,
T34.COUNTRY,
T34.ZIPCODE,
T34.STATE,
T4.NAME,
T36.CURR_PRI_LST_ID,
T27.ROW_STATUS,
T22.LOGIN,
T2.CITY,
T2.COUNTRY,
T2.ZIPCODE,
T2.COUNTY,
T2.ADDR,
T20.X_ACC_CLASS,
T20.X_FS_INLIMITS,
T20.X_PRIORITY,
T20.X_DC_LOC,
T20.X_SERV_PROV_ID,
T20.X_FS_LOC,
T20.X_LOCAL_ACCOUNT_NAME,
T20.NAME,
T20.LOC,
T20.PR_BL_ADDR_ID,
T20.PR_BL_PER_ID,
T20.PR_SHIP_ADDR_ID,
T20.PR_SHIP_PER_ID,
T20.OU_NUM,
T16.ROW_ID,
T20.PR_SRV_AGREE_ID,
T16.ROW_ID,
T15.PRIM_MARKET_CD,
T16.ROW_ID,
T14.CITY,
T14.COUNTRY,
T14.ZIPCODE,
T14.STATE,
T14.ADDR,
T35.NAME,
T32.NAME,
T8.CHRCTR_ID,
T32.PRIV_FLG,
T3.LOGIN,
T31.LOGIN,
T36.ROW_ID,
T36.MODIFICATION_NUM,
T36.CREATED_BY,
T36.LAST_UPD_BY,
T36.CREATED,
T36.LAST_UPD,
T36.CONFLICT_ID,
T36.PAR_ROW_ID,
T25.ROW_ID,
T25.MODIFICATION_NUM,
T25.CREATED_BY,
T25.LAST_UPD_BY,
T25.CREATED,
T25.LAST_UPD,
T25.CONFLICT_ID,
T25.PAR_ROW_ID,
T18.ROW_ID,
T18.MODIFICATION_NUM,
T18.CREATED_BY,
T18.LAST_UPD_BY,
T18.CREATED,
T18.LAST_UPD,
T18.CONFLICT_ID,
T18.PAR_ROW_ID,
T9.ROW_ID,
T9.MODIFICATION_NUM,
T9.CREATED_BY,
T9.LAST_UPD_BY,
T9.CREATED,
T9.LAST_UPD,
T9.CONFLICT_ID,
T9.PAR_ROW_ID,
T19.ROW_ID,
T19.MODIFICATION_NUM,
T19.CREATED_BY,
T19.LAST_UPD_BY,
T19.CREATED,
T19.LAST_UPD,
T19.CONFLICT_ID,
T19.PAR_ROW_ID,
T27.ROW_ID,
T24.ROW_ID,
T23.ROW_ID,
T2.ROW_ID,
T28.ROW_ID,
T16.ROW_ID,
T11.ROW_ID,
T14.ROW_ID,
T35.ROW_ID,
T8.ROW_ID,
T30.ROW_ID,
T7.ROW_ID
FROM
SIEBEL.S_ORG_EXT T1,
SIEBEL.S_ADDR_PER T2,
SIEBEL.S_USER T3,
SIEBEL.S_PRI_LST T4,
SIEBEL.S_PER_DEDUP_KEY T5,
SIEBEL.S_MED_SPEC T6,
SIEBEL.S_PARTY T7,
SIEBEL.S_CON_CHRCTR T8,
SIEBEL.S_CONTACT_X T9,
SIEBEL.S_POSTN T10,
SIEBEL.S_CON_ADDR T11,
SIEBEL.S_POSTN T12,
SIEBEL.S_POSTN T13,
SIEBEL.S_ADDR_PER T14,
SIEBEL.S_ORG_EXT_FNX T15,
SIEBEL.S_PARTY T16,
SIEBEL.S_PARTY T17,
SIEBEL.S_EMP_PER T18,
SIEBEL.S_CONTACT_SS T19,
SIEBEL.S_ORG_EXT T20,
SIEBEL.S_USER T21,
SIEBEL.S_USER T22,
SIEBEL.S_CON_ADDR T23,
SIEBEL.S_PARTY T24,
SIEBEL.S_CONTACT_LOYX T25,
SIEBEL.S_USER T26,
SIEBEL.S_POSTN_CON T27,
SIEBEL.S_PARTY_PER T28,
SIEBEL.S_POSTN_CON T29,
SIEBEL.S_PARTY T30,
SIEBEL.S_USER T31,
SIEBEL.S_CHRCTR T32,
SIEBEL.S_POSTN T33,
SIEBEL.S_ADDR_PER T34,
SIEBEL.S_CONTACT_XM T35,
SIEBEL.S_CONTACT T36
WHERE
T36.PR_DEPT_OU_ID = T1.PAR_ROW_ID (+) AND
T1.PR_POSTN_ID = T33.PAR_ROW_ID (+) AND
T36.PR_POSTN_ID = T13.PAR_ROW_ID (+) AND
T17.ROW_ID = T29.CON_ID (+) AND T29.POSTN_ID (+) = '1-ERPTObjMgrSqlLog' AND
T33.PR_EMP_ID = T21.PAR_ROW_ID (+) AND
T13.PR_EMP_ID = T26.PAR_ROW_ID (+) AND
T36.PR_PER_ADDR_ID = T34.ROW_ID (+) AND
T36.MED_SPEC_ID = T6.ROW_ID (+) AND
T36.CURR_PRI_LST_ID = T4.ROW_ID (+) AND
T17.ROW_ID = T5.PERSON_ID (+) AND
T17.ROW_ID = T36.PAR_ROW_ID AND
T17.ROW_ID = T25.PAR_ROW_ID (+) AND
T17.ROW_ID = T18.PAR_ROW_ID (+) AND
T17.ROW_ID = T9.PAR_ROW_ID AND
T17.ROW_ID = T19.PAR_ROW_ID (+) AND
T36.PR_POSTN_ID = T27.POSTN_ID AND T36.ROW_ID = T27.CON_ID AND
T27.POSTN_ID = T24.ROW_ID AND
T27.POSTN_ID = T12.PAR_ROW_ID (+) AND
T12.PR_EMP_ID = T22.PAR_ROW_ID (+) AND
T36.PR_OU_ADDR_ID = T23.ADDR_PER_ID (+) AND T36.PR_DEPT_OU_ID = T23.ACCNT_ID (+) AND
T36.PR_OU_ADDR_ID = T2.ROW_ID (+) AND
T36.PR_DEPT_OU_ID = T28.PARTY_ID (+) AND T36.ROW_ID = T28.PERSON_ID (+) AND
T36.PR_DEPT_OU_ID = T16.ROW_ID (+) AND
T36.PR_DEPT_OU_ID = T20.PAR_ROW_ID (+) AND
T36.PR_DEPT_OU_ID = T15.PAR_ROW_ID (+) AND
T29.PR_ADDR_ID = T11.ADDR_PER_ID (+) AND T29.CON_ID = T11.CONTACT_ID (+) AND
T29.PR_ADDR_ID = T14.ROW_ID (+) AND
T36.X_SEGMENT1 = T35.ROW_ID (+) AND
T36.PR_MKT_SEG_ID = T8.ROW_ID (+) AND
T8.CHRCTR_ID = T32.ROW_ID (+) AND
T1.PR_POSTN_ID = T30.ROW_ID (+) AND
T1.PR_POSTN_ID = T10.PAR_ROW_ID (+) AND
T10.PR_EMP_ID = T3.PAR_ROW_ID (+) AND
T36.PR_SYNC_USER_ID = T7.ROW_ID (+) AND
T36.PR_SYNC_USER_ID = T31.PAR_ROW_ID (+) AND
((T36.X_DELETE = 'N') AND
(T36.PRIV_FLG = 'N' AND T17.PARTY_TYPE_CD != 'Suspect')) AND
(T9.ATTRIB_10 = 'NObjMgrSqlLog')
ORDER BY
T36.LAST_NAME, T36.FST_NAME@afalty, the story you are telling about the order of the tables being important, from smallest to largest, et cetera, is only partially true and only when dealing with the rule based optimizer. Nowadays, almost everybody is using the cost based optimizer, so these remarks can very likely be ignored.
@original poster:
I think you are "measuring" the elapsed time by using TOAD, am I right? And you are probably writing 9 seconds, because it took TOAD 9 seconds before it could display the first records. If you would scroll down to the last record, it is likely taking much more time. A sort operation costs resources and time, but very unlikely this much.
When you want your rows sorted, all rows must have been visited before you know for sure which one is the smallest. That's why it takes longer to display the first row. Without an order by, the query can begin popping out rows much faster.
Regards,
Rob. -
Oracle query tuning : query with Order-by clause
Hi
I am having a query in my database :
SELECT * FROM SAPR3.HRP1001 WHERE "MANDT" = 990
ORDER BY
"MANDT" , "OTYPE" , "OBJID" , "PLVAR" , "RSIGN" , "RELAT" , "ISTAT" , "PRIOX" , "BEGDA" , "ENDDA" ,"VARYF" , "SEQNR" ;
Autotrace output is :
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4649 Card=171895 Byt
es=22862035)
1 0 SORT (ORDER BY) (Cost=4649 Card=171895 Bytes=22862035)
2 1 TABLE ACCESS (FULL) OF 'HRP1001' (Cost=1170 Card=171895
Bytes=22862035)
Statistics
0 recursive calls
5 db block gets
12157 consistent gets
11543 physical reads
0 redo size
38253080 bytes sent via SQL*Net to client
376841 bytes received via SQL*Net from client
34201 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
512992 rows processed
Since it is a issue with order by , it seems a PGA memory issue. there is 12GB PGA available but only 3GB gets allocated. pga_aggregate target is set in the DB. There is a index created for al the columns on order by, but it is not getting used.
pleas suggest me as I am running into major problems, i can post the output of any query u require from my side. Any help wil be highly apprciated.
Rishi> The query was alwasy spilling over to the One-Parse execution . It can be seen thru ST04N ->resource consumption-> sql work area trace.
>
> An undocumented oracle parameter smmmax_size was set which allowed for more usage of physical memory by single process and there was no spillover to the TEMP tablespaces.
>
> Also the File read time was analysed from Unix level ( From SAP thru ST04 ->filesystem wait s-> Avg rd (ms) and Ang writes (ms) which showed that reading from the File was not happening well. )
Hi Rishi,
the provided execution statistics prove the opposite:
>Statistics
>...
>0 sorts (memory)
> 1 sorts (disk)
>512992 rows processed
This indeed was a single-pass sort, which means it had to use the temp tablespace for one pass of the sorting/grouping.
Remember that Oracle distinguishes three kinds of sorts: 1. "in memory", 2. "single-pass" and 3. "multi-pass".
Only the first one won't need to spill out data to the disks. The others do this by definition.
BTW: the file read times in ST04 are aquired through Oracle V$ views and not directly from the OS - that can make a big difference sometimes.
regards,
Lars -
JDBC Driver 11.2.0.1.0 freeze after execute query with order by
Hi,
I have two tables : A and B
The table B has as foreign key the ID from table A.
I'm executing statment select id, foreing_id, name from table b order by foreing_id;
After executing query I see on database that query remains inactive and I don't receive any response on my client.
I've activate the oracle driver logs and I notice that driver stop working after these lines
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.OracleSql getSqlBytes
TRACE_30: return: [B@126f827
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.OracleSql getSqlBytes
TRACE_30: Exit
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: Enter:
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: return: 178
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: Exit
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: Enter:
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: return: 2000
Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: Exit
I'm using linux machine to execute this query, and I tried execute this same application in another linux machine and the query works.
It's very strange, for instance, this only happens if I have two records on table B using the id from table A, and also happens if only one record from table A.
Could someone help me what's going on with oracle driver?LOG ORACLE DRIVER_
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql initialize
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql computeBasicInfo
TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql computeBasicInfo
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
TRACE_30: return: 0
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Enter: true, true
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Public Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
TRACE_20: Debug: needToPrepareDefineBuffer = true
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
CONFIG: SQL: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
TRACE_16: Enter: null
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
TRACE_16: Enter: null
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection open
TRACE_16: Enter: oracle.jdbc.driver.T4CStatement@af72d8
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Enter: "T4CConnection.open"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement setCursorId
TRACE_16: Enter: 0
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement setCursorId
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection open
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement executeMaybeDescribe
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement executeMaybeDescribe
TRACE_20: Debug: rowPrefetchChanged = false, needToParse = true, needToPrepareDefineBuffer = true, columnsDefinedByUser = false
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CStatement executeForDescribe
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.execute_for_describe"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
TRACE_16: Enter: null
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
TRACE_16: Enter: null
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.doOall8"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedMessages
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedClose
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedClose
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedMessages
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
TRACE_16: Enter: true, false
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
TRACE_16: Enter: true, false
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql skipSpace
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql skipSpace
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql handleODBC
TRACE_16: Enter: NORMAL
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql handleODBC
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
TRACE_16: return: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
TRACE_30: return: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
TRACE_16: return: [B@289d2e
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
TRACE_30: return: [B@289d2e
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
TRACE_30: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: return: 178
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
TRACE_16: Exit
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: Enter:
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: return: 2000
Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
TRACE_16: Exit
DDL TABLE A*
CREATE TABLE "TABLE_A"
( "ID" NUMBER NOT NULL ENABLE,
"NAME" VARCHAR2(50 BYTE) NOT NULL ENABLE,
"TYPE" NUMBER NOT NULL ENABLE,
"VERSION" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"ISIMPLIED" NUMBER(1,0),
CONSTRAINT "TABLE_A_PK" PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
CREATE UNIQUE INDEX "TABLE_A_NAME_UNIQ" ON "TABLE_A" ("NAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
CREATE UNIQUE INDEX "TABLE_A_PK" ON "TABLE_A" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
DDL Table B:_
CREATE TABLE "TABLE_B"
( "ID" NUMBER NOT NULL ENABLE,
"TABLE_A_ID" NUMBER NOT NULL ENABLE,
"NAME" VARCHAR2(50 BYTE) NOT NULL ENABLE,
"URL" VARCHAR2(2000 BYTE) NOT NULL ENABLE,
"ISACTIVE" NUMBER(1,0) NOT NULL ENABLE,
CONSTRAINT "TABLE_B_PK" PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ENABLE,
CONSTRAINT "TABLE_A_FK" FOREIGN KEY ("TABLE_A_ID")
REFERENCES "TABLE_A" ("ID") ON DELETE CASCADE ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
CREATE UNIQUE INDEX "TABLE_B_NAME_UNIQ" ON "TABLE_B" ("NAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
CREATE UNIQUE INDEX "TABLE_B_PK" ON "TABLE_B" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "APPDATA" ;
Comments*_
After line: Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId TRACE_16: Exit the driver freeze.
I can see on DB that query keep INACTIVE and oracle driver doesn't throws any exception.
My Oracle version is 11.2.0.1.0 and as well as oracle driver, I also tried use the version 11.2.0.3.0 but the problem persists.
More facts:
If I remove or replace by another field the clause order by TABLE_A_ID from query the query works.
In this case, I have two recods on TABLE_B with TABLE_A_ID equals 2, if I remove one of these records the query works.
The bug happens only one specific machine where the number of routers is bigger than another machine that works with all possible scenarios.
Edited by: 978737 on Dec 27, 2012 12:11 PM -
EJB finder query with ORDER BY clause
Hi,
How to query the data in ordered list using Order By clause in the entity Bean.
Here is the part of My code in which i am interrested.
/* @ejbgen:finder
* signature = "Collection findAllData()"
* ejb-ql = "SELECT OBJECT(z) FROM DataProfileBean AS z"
abstract public class DataProfileBean extends EntityAdapter {
* @ejbgen:cmp-field column = DATA_PREFIX
* @ejbgen:primkey-field
* @ejbgen:local-method transaction-attribute = Required
public abstract Integer getDataPrefix();
public abstract void setDataPrefix(Integer DataPrefix);
Now what modification needs to be done in the ejb-ql query to find the DataPrefix in the sorted list.
Regards,
DilipI don't think the current spec for EJBs support ORDER BY. But Weblogic has an extension that you can use (that is, if you're using it). Here's the info: http://e-docs.bea.com/wls/docs61/ejb/cmp.html#1076421
-
Update Query with Results From another Procedure
I am not sure if you can do this or what the proper format of the command might look like.
I have a stored procedure which insert records into a database. I want to insert the records which are returned by calling another procedure. This other procedure returns a cursor object to a variable named o_rows. Can this be done using Oracle 8i?
Insert into MyTable
MyStoredProcedure(oRows);You have a couple of options.
1) You can turn your stored procedure into a pipelined table function. This would allow you to do something like
INSERT INTO myTable
SELECT *
FROM TABLE( myStoredProcedure() );I don't believe that pipelined table functions were available in 8i, however.
2) The other option would be to fetch rows from the cursor and insert those into your table. Something like
LOOP
FETCH oRows INTO col1, col2, col3, col4, ...
INSERT INTO myTable( <<column list>> )
VALUES( col1, col2, col3, col4 );Note that for simplicity I am omitting the declarations of the local variables col1, col2, etc. and the check to see whether the cursor was exhausted.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Hi all,
I'm using query builder to retrieve result. Generated query statement is:
/jcr:root/content/dam/myFolder//element(*, dam:Asset) order by jcr:content/metadata/general/@views descending
The attribute 'views' is of xtype numberfield, but of course numberfield is a textfield with only numbers allowed inside and stored as String.
Ordering by this attribute returns hits ordered in descending alphabetical order.
My question is if it's possible to execute query with ordering by number value of it's attribute, not string value.
Thanks a lot for helpThe xpath search cannot do this. So the best option (also in terms of performance) is to make that property a LONG.
Alternatively you can write a custom querybuilder predicate evaluator that can provide a custom comparator. In the query, you would then address that predicate in the orderby to use the comparator:
stringasnumber=jcr:content/metadata/general/views
orderby=stringasnumber
It could inherit from the standard JcrPropertyPredicateEvaluator or even from RangePropertyPredicateEvaluator (to support range queries as well, using filtering). Note that such a comparator will be slow if there are many results to order (since it does not make use of any search index). -
Running a SQL Stored Procedure from Power Query with Dynamic Parameters
Hi,
I want to execute a stored procedure from Power Query with dynamic parameters.
In normal process, query will look like below in Power Query. Here the value 'Dileep' is passed as a parameter value to SP.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData 'Dileep'"]
Now I want to pass the value dynamically taking from excel sheet. I can get the required excel cell value in a variable but unable to pass it to query.
Name_Parameter = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
Name_Value = Name_Parameter{0}[Value],
I have tried like below but it is not working.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData Name_Value"]
Can anyone please help me with this issue.
Thanks
DileepHi,
I got it. Below is the correct syntax.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData '" & Name_Value & "'"]
Thanks
Dileep -
Problem with performance of a query having order by, distinct clause
Hi,
I have a problem with queries having order by, distinct clause.
While its executing its taking lot of time. With DBMS_PROFILER identified the queries taking long time.
The table is having approximately 70 million rows.
Problem -1
select * from table_name order by col1;
select distinct col1,col2 from table_name;
Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.
Solution1:
Max parallel servers is 8.
select /* + parallel(table_name,8) */ * from table_name order by col1;
select /* + parallel(table_name,8) */ distinct col1, col2 from table_name ;
Solution-2:
select /* + first_rows */ * from table_name order by col1;
select /* + first_rows */ distinct col1, col2 from table_name ;
Problem-2
I am having a query with where condition on columns.
Select * from table_name where col1='value1' and col2!='value2';
Index created on col1 and col2.
As we no that not equal won't use index as it is a composite index it should use the lead column. but its not using the index.
Should i forcibly use index with hint or suggest me better solution.
Any help really appreciated.
Thanks in advanceunique wrote:
The table is having approximately 70 million rows.
select * from table_name order by col1;Do you really want 70,000,000 rows from your table without any restrictions ? And furthermore ordered output ? I honestly understand the slowness of that query.
Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.Who knows if you choosed the right solution. I would suggest to reconsider your query and the need of 70,000,000 returned rows.
Problem-2
I am having a query with where condition on columns.
Select * from table_name where col1='value1' and col2!='value2';Please, provide the explain plan, eventually the tkprof output could also help. And tables descirption AND indexes description.
And OS and Oracle version.
Nicolas. -
Is that important column order in a query with row_number function
Hi folks,
I am using Oracle 11g R2 on HP-UX machine.
I have 2 types of query with row_number and I think they are same but output of each of them are different. I changed only column order in query2.
Query 1 :
(SELECT
"LOOKUP_INPUT_SUBQUERY"."CONTRACT_SK" "CONTRACT_SK",
"LOOKUP_INPUT_SUBQUERY"."SIMCARD_SK" "SIMCARD_SK"
FROM (
SELECT row_number ()
OVER (
PARTITION BY "R_CON_SUBS_SIMCARD_LK".
"CONTRACT_SK"
ORDER BY
"R_CON_SUBS_SIMCARD_LK"."START_DATE" DESC,
"R_CON_SUBS_SIMCARD_LK"."SEQ_NUM" DESC NULLS LAST) /* EXPRESSION_3.OUTGRP1.SIRA */
"SIRA",
"R_CON_SUBS_SIMCARD_LK"."CONTRACT_SK" "CONTRACT_SK",
"R_CON_SUBS_SIMCARD_LK"."SIMCARD_SK" "SIMCARD_SK"
FROM "SRC_OZRDS"."R_CON_SUBS_SIMCARD_LK" "R_CON_SUBS_SIMCARD_LK")
"LOOKUP_INPUT_SUBQUERY"
WHERE ("LOOKUP_INPUT_SUBQUERY"."SIRA" = 1))
Output of this like that :
CONTRACT_SK SIMCARD_SK
1 1
1 3
1 4
1 5
1 6
1 11
1 12
1 14
1 15
1 16
Query 2 :
(SELECT
"LOOKUP_INPUT_SUBQUERY"."CONTRACT_SK" "CONTRACT_SK",
"LOOKUP_INPUT_SUBQUERY"."SIMCARD_SK" "SIMCARD_SK"
FROM (
SELECT
"R_CON_SUBS_SIMCARD_LK"."CONTRACT_SK" "CONTRACT_SK",
"R_CON_SUBS_SIMCARD_LK"."SIMCARD_SK" "SIMCARD_SK",
row_number ()
OVER (
PARTITION BY "R_CON_SUBS_SIMCARD_LK".
"CONTRACT_SK"
ORDER BY
"R_CON_SUBS_SIMCARD_LK"."START_DATE" DESC,
"R_CON_SUBS_SIMCARD_LK"."SEQ_NUM" DESC NULLS LAST) /* EXPRESSION_3.OUTGRP1.SIRA */
"SIRA"
FROM "SRC_OZRDS"."R_CON_SUBS_SIMCARD_LK" "R_CON_SUBS_SIMCARD_LK")
"LOOKUP_INPUT_SUBQUERY"
WHERE ("LOOKUP_INPUT_SUBQUERY"."SIRA" = 1))
Output of this like that:
2 874812
7 70097256
8 18734091
9 158024
10 815397739
13 22657919
19 83177779
20 82579529
22 5829949
23 35348926
25 3865978
I expected the second output, because there are lots of contract sk but there is one contract_sk in first query result. i did not get the point. What is the problem ?user8649469 wrote:
I changed only column order in query2.So what else do you expect? If you order, for example, by last name, fist name don't you think rows will be returned in a different order (and therefore same row will have different row number) than ordering by first name, last name?
SY. -
How to view a BI query with anonymous user in the portal
<b>Hi Gurus,</b>
Does anybody knows how to view a BI query in the portal with anonymous user?
Cause when i try to view a query the portal always ask for authentification. And i don't want to sign with a user cause my portal is for everybody and if the user logged in it shows the roles that previously were assigned.
I have the Netweaver 2004 with SP9
<b>Thank you Very Much</b>do you have sso configured between portal and BW server, if yes the authentication pop up should not come.
if you dont want to do sso between portal and bw server and still want to logon to BW query with anonymous user,
in you bw server go to transaction sicf and navigate to DEFAULT_HOST->SAP->BW->BEX and double click on bex node in the resulting window, log on details section provide a default userid/password
Raja -
How to insert some strings in a query with the clausule 'in' in a procedure
Hello fellows.
Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
I tell us my problem with an example:
I want to use this select but introducing a variable instead the 'value1', 'value2':
select * from table1 where field1 in ('value1', 'value2');
if I declare the variable var1 as:
TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
and I use it as:
select * from table1 where field1 in (TC_VAR1);
It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
select * from table1 where field1 in ('value1, value2');
If I use the data type TABLE, I don't know how to use well:
TYPE varchar2_table IS TABLE OF VARCHAR2(10);
tb_var varchar2_table;
select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
A curious case is that if I have a sql script (for example script1.sh) with this query:
select * fromt able1 where field1 in (&1)
and I invoke this script as
script1.sh "'''value1'',''value2'''". It works
Can anybody helps me?.
Thanks.Thanks to all. Really.
First, sorry for my English. It's horrible. Thank to all for understand it (my English).
I've resolved my problem with these links:
ORA-22905: cannot access rows from a non-nested table item
and
http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
At last, I have used someting like this:
DECLARE
number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
BEGIN
FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
UNION ALL
SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
NULL;
END LOOP;
END;
but first I had to create the type NUM_ARRAY like this:
CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
Edited by: user12249099 on 08-sep-2011 7:37
Edited by: user12249099 on 08-sep-2011 7:37
Maybe you are looking for
-
Now the previous version won't open. I downloaded and tried to instal 6.0 without software update, which failed, and my old 5.5.3 Airport Utility still won't open. iTunes no longer recognizes my airport express. Error Message: None of the selected up
-
The icon is blue with a white firefox logo on it. My only options are to "Burn 'Firefox'" or "Eject 'Firefox'" when I click on it to edit it, but I cannot cut, paste, or move to trash. It won't let me. When I click on "Eject 'firefox'" it says "The d
-
Family Apple IDs and iCloud SubAccounts
Our family has just purchased and is migrating to 3 iPhones, 1 MacBook Pro, 1 iMac and 2 iPads. We have 4 users in our family - 2 parents and 2 kids. Your recommendations on how to best set-up our family in terms of Apple ID's and iCloud Accounts wou
-
How to get the page number when click the(Next page) Icon on Tableview
Hi all, I had implemented a tableview in one of the Views that I had implemented for a BSP application. I am using MVC framework. Let us assume when we execute the BSP and a table view got 11 pages. How I can keep track of the page number when
-
Apple Genius Bar Triage Hard Drive
I was recently at the apple store and noticed that one of the technicians was using an external hard drive with 10.4 triage, 10.5 triage, and 10.6 triage. Where could I get the contents of that hard drive?