Query Needed for Partitioning table
Hi,
I have created a table called Test. There is a column named business_name.
There are several businesses like ABC,BCD,ADE....
There will be lakhs of rows corresponding to each business, i mean there will be lakhs of entires corresponding to ABC,BCD....
So i like to partition the table according to business_name so that the search will be more faster.As we had partitioned according to the business_name, i hope we need to search only on the partition corresponding to the particular business.
can any one provide the Query to partition the table ' TEST ' according to the column ' business_name ' .
Also can anyone provide Query to modify the already existing table ' TEST ' to incorporate partition for the column ' business_name '.
We can partiton a table by the following
create table Generalledger (
record_id number,
business_name varchar2(3)
sales_dt date,
amount number(10)
partition by list (business_name)
partition ct values ('ABC'),
partition ca values ('BCD'),
partition def values (default)
But if we dont know the values like 'ABC' , 'BCD'
....how can we do the partitionuse SQL to generate part (or all) of your DDL statement. The following will output one partition statement for each business_name:
SELECT DISTINCT 'partition p_' || BUSINESS_NAME || ' values (''' ||
BUSINESS_NAME || '''),'
FROM GENERALLEDGER;
Similar Messages
-
Extract DDL for Partitioned tables in Oracle 8i
Hi
I am currently working on an Oracle 8i database. I have a need to extract the DDL of the existing tables & indexes. Dont need a schema level DDL extract, i just need it for a couple of tables and the corresponding indexes. I am currently using PL/SQL Developer a third party tool which is okay for extracting DDL for Non Partitioned tables, but when it comes to getting the DDL for PARTITIONED tables, it doesnt give me the partition information nor the tablespace information. We dont have a license for Toad or any other tools to get the DDL's. I also dont have the export/import privs on the DB. I need a free ware that can give me the DDL for the existing partitioned tables or atleast a query that I can run against the regular DBA views, which can give me the DDL along with Storage clause, the tablespace, indexes, grants & constraints.
Thanks in Advance
ChandraI also dont have the export/import privs on the DB. I need a
free ware that can give me the DDL for the existing
partitioned tables or atleast a query that I can run
against the regular DBA views, which can give me the
DDL along with Storage clause, the tablespace,
indexes, grants & constraints.But you (or the owner or the tables you connect with) should have export/import privs on its on tables (i.e the two tables). So use the User Views instead of DBA Views.
USER_TABLES, USER_TAB_PARTITIONS etc -
Auto stats gathering for partitioned table
Hi,
We are in 10gR2 in sun solaris. We are using auto stats gathering for our DB. Here is my question,
i know oracle gather statistics of the table, if the table changes more than 10%. How this work out for partitioned table? If the partition table changes more than 10% will last partition analyzed or the full table. We have partitioned based on insertion date.
Appreciate your responds.
Regards,
Satheesh Shanmugam
http://borndba.comI hope it will be only current partition which has teh stale statistics will be gathered the stastics instead of full table.
Anil Malkai -
Keeping stats up to date for partitioned tables
Hi,
Oracle version 10.2.0.4
I have a partioned table. I would like to keep stats up-to-date.
Can I just run a single command to update table stats, indexes and partitions please?
exec dbms_stats.gather_table_stats(user, 'TABLE', cascade=>true)or I also need to run exec dbms_stats.gather_table_stats(user, 'TABLE', granularity=>partition)
thanks,
Ashok
Edited by: 902986 on 27-Oct-2012 11:06
Edited by: 902986 on 27-Oct-2012 11:07thanks
yes there were many indexes on the original non-partitioned table and I have created another table partitioned and now populating it with the data from the original table. the new table is partitioned on a date range column for all years before 2012, then for 2012, 2013 and so forth.
the indexes are all created locally bar a unique index (as per original table), created globally to enforce uniqueness across the table itself. the search will always look to year to date say 1st jan 2012 tilll today for risk analysis. the partition is on that date column and there is also a local index on that date column as well, to avoid table scan (tested with disabling that index, predictably did table scan and was less efficient).
in a DW environment, I don't see much value in having global index bar for primary key/unique constraint. I do realise that if the query crosses more than one partition, say 2 partitions, there will be two b-tree local index scans rather than one, but that would be rare (from the way they query the table).
therefore my plan is to perform a full table stats with cascade=>true and measure the time it takes and plan to do the same if the maintenance window allows it.
thanks again for your help
Edited by: 902986 on 28-Oct-2012 13:24 -
SQL coding for partitioned tables
Hi My tables are partitioned into 4 different partitions.. each one representing each quarter of a year.. do i need to specify the partition name in my sql query to grab the data or does oracle have the intelligence to go this partition based on my select statement..
say q1, q2,q3,q4 table partitions and the table name is y1
can i say
<code> select * from y1 where date ='01/01/2005'</code>
does this above written code takes you directly to the partition where this data is located..
if it does how do we know that in the execution plan that it wasnot scanning the full table but rather one partition..
thanks in advancehave a look at the explain plan and you will see how oracle acces the partitioned table.
All Oracle documentation can be found under
http://otn.oracle.com/pls/db92/db92.docindex?remark=homepage
You will probably find answer to your question under
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/toc.htm
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/toc.htm -
Partition pruning not working for partitioned table joins
Hi,
We are joining 4 partitioned tables on partition column & other key columns. And we are filtering the driving table on partition key. But explain plan is showing that all tables except the driving table are not partition pruning and scanning all partitions.Is there any limitation that filter condition cannot be dynamic?
Thanks a lot in advance.
Here are the details...
SELECT a.pay_prd_id,
a.a_id,
a.a_evnt_no
FROM b,
c,
a,
d
WHERE ( a.pay_prd_id = b.pay_prd_id ---partition range all
AND a.a_evnt_no = b.b_evnt_no
AND a.a_id = b.b_id
AND ( a.pay_prd_id = c.pay_prd_id---partition range all
AND a.a_evnt_no = c.c_evnt_no
AND a.a_id = c.c_id
AND ( a.pay_prd_id = d.pay_prd_id---partition range all
AND a.a_evnt_no = d.d_evnt_no
AND a.a_id = d.d_id
AND (a.pay_prd_id = ---partition range single
CASE '201202'
WHEN 'YYYYMM'
THEN (SELECT min(pay_prd_id)
FROM pay_prd
WHERE pay_prd_stat_cd = 2)
ELSE TO_NUMBER ('201202', '999999')
END
DDLs.
create table pay_prd
pay_prd_id number(6),
pay_prd_stat_cd integer,
pay_prd_stat_desc varchar2(20),
a_last_upd_dt DATE
insert into pay_prd
select 201202,2,'OPEN',sysdate from dual
union all
select 201201,1,'CLOSE',sysdate from dual
union all
select 201112,1,'CLOSE',sysdate from dual
union all
select 201111,1,'CLOSE',sysdate from dual
union all
select 201110,1,'CLOSE',sysdate from dual
union all
select 201109,1,'CLOSE',sysdate from dual
CREATE TABLE A
(PAY_PRD_ID NUMBER(6) NOT NULL,
A_ID NUMBER(9) NOT NULL,
A_EVNT_NO NUMBER(3) NOT NULL,
A_DAYS NUMBER(3),
A_LAST_UPD_DT DATE
PARTITION BY RANGE (PAY_PRD_ID)
INTERVAL( 1)
PARTITION A_0001 VALUES LESS THAN (201504)
ENABLE ROW MOVEMENT;
ALTER TABLE A ADD CONSTRAINT A_PK PRIMARY KEY (PAY_PRD_ID,A_ID,A_EVNT_NO) USING INDEX LOCAL;
insert into a
select 201202,1111,1,65,sysdate from dual
union all
select 201202,1111,2,75,sysdate from dual
union all
select 201202,1111,3,85,sysdate from dual
union all
select 201202,1111,4,95,sysdate from dual
CREATE TABLE B
(PAY_PRD_ID NUMBER(6) NOT NULL,
B_ID NUMBER(9) NOT NULL,
B_EVNT_NO NUMBER(3) NOT NULL,
B_DAYS NUMBER(3),
B_LAST_UPD_DT DATE
PARTITION BY RANGE (PAY_PRD_ID)
INTERVAL( 1)
PARTITION B_0001 VALUES LESS THAN (201504)
ENABLE ROW MOVEMENT;
ALTER TABLE B ADD CONSTRAINT B_PK PRIMARY KEY (PAY_PRD_ID,B_ID,B_EVNT_NO) USING INDEX LOCAL;
insert into b
select 201202,1111,1,15,sysdate from dual
union all
select 201202,1111,2,25,sysdate from dual
union all
select 201202,1111,3,35,sysdate from dual
union all
select 201202,1111,4,45,sysdate from dual
CREATE TABLE C
(PAY_PRD_ID NUMBER(6) NOT NULL,
C_ID NUMBER(9) NOT NULL,
C_EVNT_NO NUMBER(3) NOT NULL,
C_DAYS NUMBER(3),
C_LAST_UPD_DT DATE
PARTITION BY RANGE (PAY_PRD_ID)
INTERVAL( 1)
PARTITION C_0001 VALUES LESS THAN (201504)
ENABLE ROW MOVEMENT;
ALTER TABLE C ADD CONSTRAINT C_PK PRIMARY KEY (PAY_PRD_ID,C_ID,C_EVNT_NO) USING INDEX LOCAL;
insert into c
select 201202,1111,1,33,sysdate from dual
union all
select 201202,1111,2,44,sysdate from dual
union all
select 201202,1111,3,55,sysdate from dual
union all
select 201202,1111,4,66,sysdate from dual
CREATE TABLE D
(PAY_PRD_ID NUMBER(6) NOT NULL,
D_ID NUMBER(9) NOT NULL,
D_EVNT_NO NUMBER(3) NOT NULL,
D_DAYS NUMBER(3),
D_LAST_UPD_DT DATE
PARTITION BY RANGE (PAY_PRD_ID)
INTERVAL( 1)
PARTITION D_0001 VALUES LESS THAN (201504)
ENABLE ROW MOVEMENT;
ALTER TABLE D ADD CONSTRAINT D_PK PRIMARY KEY (PAY_PRD_ID,D_ID,D_EVNT_NO) USING INDEX LOCAL;
insert into c
select 201202,1111,1,33,sysdate from dual
union all
select 201202,1111,2,44,sysdate from dual
union all
select 201202,1111,3,55,sysdate from dual
union all
select 201202,1111,4,66,sysdate from dualBelow query generated from Business Objects and submitted to Database (the case statement is generated by BO). Cant we use Case/Subquery/Decode etc for the partitioned column? We are assuming that the case causing the issue to not to dynamic partition elimination on the other joined partitioned tables (TAB_B_RPT, TAB_C_RPT).
SELECT TAB_D_RPT.acvy_amt,
TAB_A_RPT.itnt_typ_desc,
TAB_A_RPT.ls_typ_desc,
TAB_A_RPT.evnt_no,
TAB_C_RPT.pay_prd_id,
TAB_B_RPT.id,
TAB_A_RPT.to_mdfy,
TAB_A_RPT.stat_desc
FROM TAB_D_RPT,
TAB_C_RPT fee_rpt,
TAB_C_RPT,
TAB_A_RPT,
TAB_B_RPT
WHERE (TAB_B_RPT.id = TAB_A_RPT.id)
AND ( TAB_A_RPT.pay_prd_id = TAB_D_RPT.pay_prd_id -- expecting Partition Range Single, but doing Partition Range ALL
AND TAB_A_RPT.evnt_no = TAB_D_RPT.evnt_no
AND TAB_A_RPT.id = TAB_D_RPT.id
AND ( TAB_A_RPT.pay_prd_id = TAB_C_RPT.pay_prd_id -- expecting Partition Range Single, but doing Partition Range ALL
AND TAB_A_RPT.evnt_no = TAB_C_RPT.evnt_no
AND TAB_A_RPT.id = TAB_C_RPT.id
AND ( TAB_A_RPT.pay_prd_id = fee_rpt.pay_prd_id -- expecting Partition Range Single
AND TAB_A_RPT.evnt_no = fee_rpt.evnt_no
AND TAB_A_RPT.id = fee_rpt.id
AND (TAB_A_RPT.rwnd_ind = 'N')
AND (TAB_A_RPT.pay_prd_id =
CASE '201202'
WHEN 'YYYYMM'
THEN (SELECT DISTINCT pay_prd.pay_prd_id
FROM pay_prd
WHERE pay_prd.stat_cd = 2)
ELSE TO_NUMBER ('201202', '999999')
END
And its explain plan is...
Plan
SELECT STATEMENT ALL_ROWS Cost: 79 K Bytes: 641 M Cardinality: 3 M
18 HASH JOIN Cost: 79 K Bytes: 641 M Cardinality: 3 M
3 PART JOIN FILTER CREATE SYS.:BF0000 Cost: 7 K Bytes: 72 M Cardinality: 3 M
2 PARTITION RANGE ALL Cost: 7 K Bytes: 72 M Cardinality: 3 M Partition #: 3 Partitions accessed #1 - #1048575
1 TABLE ACCESS FULL TABLE TAB_D_RPT Cost: 7 K Bytes: 72 M Cardinality: 3 M Partition #: 3 Partitions accessed #1 - #1048575
17 HASH JOIN Cost: 57 K Bytes: 182 M Cardinality: 874 K
14 PART JOIN FILTER CREATE SYS.:BF0001 Cost: 38 K Bytes: 87 M Cardinality: 914 K
13 HASH JOIN Cost: 38 K Bytes: 87 M Cardinality: 914 K
6 PART JOIN FILTER CREATE SYS.:BF0002 Cost: 8 K Bytes: 17 M Cardinality: 939 K
5 PARTITION RANGE ALL Cost: 8 K Bytes: 17 M Cardinality: 939 K Partition #: 9 Partitions accessed #1 - #1048575
4 TABLE ACCESS FULL TABLE TAB_C_RPT Cost: 8 K Bytes: 17 M Cardinality: 939 K Partition #: 9 Partitions accessed #1 - #1048575
12 HASH JOIN Cost: 24 K Bytes: 74 M Cardinality: 957 K
7 INDEX FAST FULL SCAN INDEX (UNIQUE) TAB_B_RPT_PK Cost: 675 Bytes: 10 M Cardinality: 941 K
11 PARTITION RANGE SINGLE Cost: 18 K Bytes: 65 M Cardinality: 970 K Partition #: 13 Partitions accessed #KEY(AP)
10 TABLE ACCESS FULL TABLE TAB_A_RPT Cost: 18 K Bytes: 65 M Cardinality: 970 K Partition #: 13 Partitions accessed #KEY(AP)
9 HASH UNIQUE Cost: 4 Bytes: 14 Cardinality: 2
8 TABLE ACCESS FULL TABLE PAY_PRD Cost: 3 Bytes: 14 Cardinality: 2
16 PARTITION RANGE JOIN-FILTER Cost: 8 K Bytes: 106 M Cardinality: 939 K Partition #: 17 Partitions accessed #:BF0001
15 TABLE ACCESS FULL TABLE TAB_C_RPT Cost: 8 K Bytes: 106 M Cardinality: 939 K Partition #: 17 Partitions accessed #:BF0001
Thanks Again. -
SYNC(EVERY interval ) deployment for Partitioned Tables
I am wondering if anyone has deployed the SYNC(EVERY "SYSDATE + interval") style in a Partition table environment where there is a large number of partitions but only a few the most recent 7days (lets say 30 days) have any inserts/updates. As I understand it, the SYNC(EVERY interval) creates a DBMS_SCHEDULER job for each partition and the job will submit as per the interval. We have about 5000 partitions on any given day; partitions get dropped and we add a new one for the fututre (we keep 30 days ahead).
1. Is it possible to modify the interval in these auto created Jobs? For Partitions older thasn X days i would want to run the job every Z hours
2. Disable the future jobs until the day required (enable 10 minutes before the partition becomes "active" -- gets data
RegardsHi,
you can read about this in the manual (http://docs.oracle.com/cd/E11882_01/text.112/e24436/csql.htm#i997677). The manual says: "Each partition of a locally partitioned index can have its own type of sync (ON COMMIT, EVERY, or MANUAL). The type of sync specified in master parameter strings applies to all index partitions unless a partition specifies its own type." So it is possible to set for each partition its own sync type. This is possible with an ALTER statement:
ALTER INDEX index_name MODIFY PARTITION partition_name PARAMETER (paramstring)1. With the above alter you can change it
2. You can put a partition to MANUAL and then synchronize when necessary.
So if you know when the partition needs to change, you can change it possible with another job or procedure.
Herald ten Dam
http://htendam.wordpress.com -
Select for partitioned table, will this work with sign?
Hi,
I have partitioned table and select for it like :
PARTITION BY RANGE ( "INDATE" )
( PARTITION "PRT_20091201" VALUES LESS THAN (TO_DATE(' 2009-12-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')...
SELECT COLUMN_LIST FROM TABLE1 WHERE
( indate >= to_date(t_indate || t_timefrom, 'mm/dd/yyyy HH24:MI:SS')) AND
( indate <= to_date(t_indate || t_timeto, 'mm/dd/yyyy HH24:MI:SS')) AND... so selecting all info for the given date withing specifiied time period, and I'm using >= condition on partitioned column, do you think it will work correctly getting directly to the single partition, or Oralce requires me put strictly = sign for that column, and then additioanly I can probably select time period, something like:
SELECT COLUMN_LIST FROM TABLE1 WHERE
( indate = to_date(t_indate , 'mm/dd/yyyy')) AND
( trim_to_time(indate) >= to_char(t_timefrom, ' HH24:MI:SS')) AND
( trim_to_time(indate) <= to_char( t_timeto, ' HH24:MI:SS')) AND... Tx all
Trtrento wrote:
Hi,
I have partitioned table and select for it like :
PARTITION BY RANGE ( "INDATE" )
( PARTITION "PRT_20091201" VALUES LESS THAN (TO_DATE(' 2009-12-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')...
SELECT COLUMN_LIST FROM TABLE1 WHERE
( indate >= to_date(t_indate || t_timefrom, 'mm/dd/yyyy HH24:MI:SS')) AND
( indate <= to_date(t_indate || t_timeto, 'mm/dd/yyyy HH24:MI:SS')) AND... so selecting all info for the given date withing specifiied time period, and I'm using >= condition on partitioned column, do you think it will work correctly getting directly to the single partition, or Oralce requires me put strictly = sign for that column, and then additioanly I can probably select time period, something like:
SELECT COLUMN_LIST FROM TABLE1 WHERE
( indate = to_date(t_indate , 'mm/dd/yyyy')) AND
( trim_to_time(indate) >= to_char(t_timefrom, ' HH24:MI:SS')) AND
( trim_to_time(indate) <= to_char( t_timeto, ' HH24:MI:SS')) AND... Tx all
TrI agree with David that the first example looked okay, but you should test to make sure. You can check individual partition contents by executing a query using the PARTITION option to specifiy a specific partition to check the values there. -
CTAS using dbms_metadata.get_ddl for Partitioned table
Hi,
I would like to create a temporary table from a partitioned table using CTAS. I plan to use the following steps in a PL/SQL procedure:
1. Use dbms_metadata.get_ddl to get the script
2. Use raplace function to change the tablename to temptable
3. execute the script to get the temp table created.
SQL> create or replace procedure p1 as
2 l_clob clob;
3 str long;
4 begin
5 SELECT dbms_metadata.get_ddl('TABLE', 'FACT_TABLE','USER1') into l_clob FROM DUAL;
6 dbms_output.put_line('CLOB Length:'||dbms_lob.getlength(l_clob));
7 str:=dbms_lob.substr(l_clob,dbms_lob.getlength(l_clob),1);
8 dbms_output.put_line('DDL:'||str);
9 end;
12 /
Procedure created.
SQL> exec p1;
CLOB Length:73376
DDL:
PL/SQL procedure successfully completed.
I cannot see the DDL at all. Please help.Thanks Adam. The following piece of code is supposed to do that. But, its failing because the dbms_lob.substr(l_clob,4000,4000*v_intIdx +1); is putting newline and therefore dbms_sql.parse
is failing.
Please advice.
create table my_metadata(stmt_no number, ddl_stmt clob);
CREATE OR REPLACE package USER1.genTempTable is
procedure getDDL;
procedure createTempTab;
end;
CREATE OR REPLACE package body USER1.genTempTable is
procedure getDDL as
Description: get a DDL from a partitioned table and change the table name
Reference: Q: How Could I Format The Output From Dbms_metadata.Get_ddl Utility? [ID 394143.1]
l_clob clob := empty_clob();
str long;
l_dummy varchar2(25);
dbms_lob does not have any replace function; the following function is a trick to do that
procedure lob_replace( p_lob in out clob, p_what in varchar2, p_with in varchar2 )as
n number;
begin
n := dbms_lob.instr( p_lob, p_what );
if ( nvl(n,0) > 0 )
then
dbms_lob.copy( p_lob,
p_lob,
dbms_lob.getlength(p_lob),
n+length(p_with),
n+length(p_what) );
dbms_lob.write( p_lob, length(p_with), n, p_with );
if ( length(p_what) > length(p_with) )
then
dbms_lob.trim( p_lob,
dbms_lob.getlength(p_lob)-(length(p_what)-length(p_with)) );
end if;
end if;
end lob_replace;
begin
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
execute immediate 'truncate table my_metadata';
-- Get DDL
SELECT dbms_metadata.get_ddl('TABLE', 'FACT','USER1') into l_clob FROM DUAL;
-- Insert the DDL into the metadata table
insert into my_metadata values(1,l_clob);
commit;
-- Change the table name into a temporary table
select ddl_stmt into l_clob from my_metadata where stmt_no =1 for update;
lob_replace(l_clob,'"FACT"','"FACT_T"');
insert into my_metadata values(2,l_clob);
commit;
-- execute immediate l_clob; <---- Cannot be executed in 10.2.0.5; supported in 11gR2
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');
end getDDL;
Procedure to create temporary table
procedure createTempTab as
v_intCur pls_integer;
v_intIdx pls_integer;
v_intNumRows pls_integer;
v_vcStmt dbms_sql.varchar2a;
l_clob clob := empty_clob();
l_str varchar2(4000);
l_length number;
l_loops number;
begin
select ddl_stmt into l_clob from my_metadata where stmt_no=2;
l_length := dbms_lob.getlength(l_clob);
l_loops := ceil(l_length/4000);
for v_intIdx in 0..l_loops loop
l_str:=dbms_lob.substr(l_clob,4000,4000*v_intIdx +1);
l_str := replace(l_str,chr(10),'');
l_str := replace(l_str,chr(13),'');
l_str := replace(l_str,chr(9),'');
v_vcStmt(v_intIdx) := l_str;
end loop;
for v_intIdx in 0..l_loops loop
dbms_output.put_line(v_vcStmt(v_intIdx));
end loop;
v_intCur := dbms_sql.open_cursor;
dbms_sql.parse(
c => v_intCur,
statement => v_vcStmt,
lb => 0,
--ub => v_intIdx,
ub => l_loops,
lfflg => true,
language_flag => dbms_sql.native);
v_intNumRows := dbms_sql.execute(v_intCur);
dbms_sql.close_cursor(v_intCur);
end createTempTab;
end;
/ -
Replication For Partitioned Table
Well , I have a partitioned Table having partition on Date Field. Table Contains composite primary Key Date Field + Connection Id . Table Contains approx 30 Million Records.
Now when i m goin for replication setup , created materialized view on the basis of primary key , the fast refresh process takin time approx 3 hrs for refreshing 80,000 records on LAN environment.
Before partitioning this table the same refresh was taking only 20 Minutes.
can any body help me out to fasten up the refresh ?What version of oracle are you using? What type of partitioning you are using on the table? Is the materialized view partitioned? What type of refresh mechanism are you using?(REFRESH FAST or REFRESH FORCE or REFRESH COMPLETE)? Is it ON DEMAND or ON COMMIT?
-
Set table level degree for partitioned table
Hi all,
Usually, we set degree 2 or 4 to big tables. In this case, CBO will choose parallel select for these tables if possible.
Let assume one case that is table1 joins table2. non-partitioned Table1 has 20m rows and has degree 2. partitioned table2 has 50m rows and has no parallel degree.
When I checked the execution plan, CBO uses parallel execution and uses PX BLOCK ITERATOR on table1 as expected. But I don't know whether table2 is selected in parallel, too.
I mean I am not sure whether CBO launches slave processes against table2 or just select table2 as a whole.
And with your tuning or architecture experiences, do you think whehther we should set degree for a partitioned table as the partitioned table can be parallelized based on partitions?
best regards,
Leonuser12064076 wrote:
And with your tuning or architecture experiences, do you think whether we should set degree for a partitioned table as the partitioned table can be parallelized based on partitions?What version of Oracle?
A site I worked at recently preferred not to hard-code the degree but to let Oracle choose it at runtime; they felt it offered better allocation of system load than hard-coding the values. They were on 10g release 2. -
"db file scattered read" too high and Query going for full table scan-Why ?
Hi,
I had a big table of around 200mb and had a index on it.
In my query I am using the where clause which has to use the
index. I am neither using any not null condition
nor using any function on the index fields.
Still my query is not using the index.
It is going for full table scan.
Also the statspack report is showing the
"db file scattered read" too high.
Can any body help and suggest me why this is happenning.
Also tell me the possible solution for it.
Thanks
Arun Tayal"db file scattered read" are physical reads/multi block reads. This wait occurs when the session reading data blocks from disk and writing into the memory.
Take the execution plan of the query and see what is wrong and why the index is not being used.
However, FTS are not always bad. By the way, what is your db_block_size and db_file_multiblock_read_count values?
If those values are set to high, Optimizer always favour FTS thinking that reading multiblock is always faster than single reads (index scans).
Dont see oracle not using index, just find out why oracle is not using index. Use the INDEX hint to force optimizer to use index. Take the execution with/witout index and compare the cardinality,cost and of course, logical reads.
Jaffar
Message was edited by:
The Human Fly -
EA 4.0 - Icon for partitioned tables changed
The icon in the tree list changed in the EA Version 4.0 to the normal table icon.
Best will be to get an icon with a small "p" inside so that partitioned tables can be seen in the tree list.CREATE TABLE "ANPQUALITY"."PART_REPLICATION"
( "UNIQUEPART_ID" VARCHAR2(80 BYTE) NOT NULL ENABLE,
"IDENTIFIER_TYPE" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"DATE_CHANGED" TIMESTAMP (6) WITH TIME ZONE,
"TIME_STAMP" TIMESTAMP (6) WITH TIME ZONE,
"V_DATE_CHANGED" DATE GENERATED ALWAYS AS (TO_DATE(TO_CHAR("DATE_CHANGED",'YYYYMMDD HH24:MI:SS'),'YYYYMMDD HH24:MI:SS')) VIRTUAL VISIBLE ,
CONSTRAINT "PART_REPLICATION_PK" PRIMARY KEY ("UNIQUEPART_ID", "IDENTIFIER_TYPE") USING INDEX PCTFREE 5 INITRANS 8 MAXTRANS 255
COMPUTE STATISTICS STORAGE(INITIAL 104857600 NEXT 104857600 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE TRACE ENABLE)
PCTFREE 5 PCTUSED 40 INITRANS 8 MAXTRANS 255 COMPRESS FOR OLTP STORAGE
(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TRACE" LOB ("PART_DATA") STORE AS BASICFILE (
ENABLE STORAGE IN ROW CHUNK 32768 RETENTION NOCACHE LOGGING STORAGE( BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
PARTITION BY RANGE ("V_DATE_CHANGED") INTERVAL (NUMTOYMINTERVAL(1,'MONTH') )
(PARTITION "P_00" VALUES LESS THAN (TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 5 PCTUSED 40 INITRANS 8 MAXTRANS 255
STORAGE(INITIAL 104857600 NEXT 104857600 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TRACE" LOB ("PART_DATA") STORE AS BASICFILE (
TABLESPACE "TRACE" ENABLE STORAGE IN ROW CHUNK 32768 RETENTION NOCACHE LOGGING
STORAGE(INITIAL 104857600 NEXT 104857600 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
COMPRESS FOR OLTP -
Query statement for internal table
is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx
Hi Daphne,
You use SELECT statement to read data from database table but not from Internal table.
For reading data from Internal table, you have to use READ statement.
Syntax:
READ TABLE itab { table_key
| free_key
| index } result.
Effect of using read statement:
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
Reward if usefull
thanks
swaroop -
Pagination query help needed for large table - force a different index
I'm using a slight modification of the pagination query from over at Ask Tom's: [http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html]
Mine looks like this when fetching the first 100 rows of all members with last name Smith, ordered by join date:
SELECT members.*
FROM members,
SELECT RID, rownum rnum
FROM
SELECT rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
WHERE rownum <= 100
WHERE rnum >= 1
and RID = members.rowidThe difference between this and the one at Ask Tom's is that my innermost query just returns the ROWID. Then in the outermost query we join the ROWIDs returned to the members table, after we have pruned the ROWIDs down to only the chunk of 100 we want. This makes it MUCH faster (verifiably) on our large tables, as it is able to use the index on the innermost query (well... read on).
The problem I have is this:
SELECT rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindateThis will use the index for the predicate column (last_name) instead of the unique index I have defined for the joindate column (joindate, sequence). (Verifiable with explain plan). It is much slower this way on a large table. So I can hint it using either of the following methods:
SELECT /*+ index(members, joindate_idx) */ rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
SELECT /*+ first_rows(100) */ rowid as RID
FROM members
WHERE last_name = 'Smith'
ORDER BY joindateEither way, it now uses the index of the ORDER BY column (joindate_idx), so now it is much faster as it does not have to do a sort (remember, VERY large table, millions of records). So that seems good. But now, on my outermost query, I join the rowid with the meaningful columns of data from the members table, as commented below:
SELECT members.* -- Select all data from members table
FROM members, -- members table added to FROM clause
SELECT RID, rownum rnum
FROM
SELECT /*+ index(members, joindate_idx) */ rowid as RID -- Hint is ignored now that I am joining in the outer query
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate
WHERE rownum <= 100
WHERE rnum >= 1
and RID = members.rowid -- Merge the members table on the rowid we pulled from the inner queriesOnce I do this join, it goes back to using the predicate index (last_name) and has to perform the sort once it finds all matching values (which can be a lot in this table, there is high cardinality on some columns).
So my question is, in the full query above, is there any way I can get it to use the ORDER BY column for indexing to prevent it from having to do a sort? The join is what causes it to revert back to using the predicate index, even with hints. Remove the join and just return the ROWIDs for those 100 records and it flies, even on 10 million records.
It'd be great if there was some generic hint that could accomplish this, such that if we change the table/columns/indexes, we don't need to change the hint (the FIRST_ROWS hint is a good example of this, while the INDEX hint is the opposite), but any help would be appreciated. I can provide explain plans for any of the above if needed.
Thanks!Lakmal Rajapakse wrote:
OK here is an example to illustrate the advantage:
SQL> set autot traceonly
SQL> select * from (
2 select a.*, rownum x from
3 (
4 select a.* from aoswf.events a
5 order by EVENT_DATETIME
6 ) a
7 where rownum <= 1200
8 )
9 where x >= 1100
10 /
101 rows selected.
Execution Plan
Plan hash value: 3711662397
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 521K| 192 (0)| 00:00:03 |
|* 1 | VIEW | | 1200 | 521K| 192 (0)| 00:00:03 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 1200 | 506K| 192 (0)| 00:00:03 |
| 4 | TABLE ACCESS BY INDEX ROWID| EVENTS | 253M| 34G| 192 (0)| 00:00:03 |
| 5 | INDEX FULL SCAN | EVEN_IDX02 | 1200 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("X">=1100)
2 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
443 consistent gets
0 physical reads
0 redo size
25203 bytes sent via SQL*Net to client
281 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
101 rows processed
SQL>
SQL>
SQL> select * from aoswf.events a, (
2 select rid, rownum x from
3 (
4 select rowid rid from aoswf.events a
5 order by EVENT_DATETIME
6 ) a
7 where rownum <= 1200
8 ) b
9 where x >= 1100
10 and a.rowid = rid
11 /
101 rows selected.
Execution Plan
Plan hash value: 2308864810
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 201K| 261K (1)| 00:52:21 |
| 1 | NESTED LOOPS | | 1200 | 201K| 261K (1)| 00:52:21 |
|* 2 | VIEW | | 1200 | 30000 | 260K (1)| 00:52:06 |
|* 3 | COUNT STOPKEY | | | | | |
| 4 | VIEW | | 253M| 2895M| 260K (1)| 00:52:06 |
| 5 | INDEX FULL SCAN | EVEN_IDX02 | 253M| 4826M| 260K (1)| 00:52:06 |
| 6 | TABLE ACCESS BY USER ROWID| EVENTS | 1 | 147 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("X">=1100)
3 - filter(ROWNUM<=1200)
Statistics
8 recursive calls
0 db block gets
117 consistent gets
0 physical reads
0 redo size
27539 bytes sent via SQL*Net to client
281 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
101 rows processed
Lakmal (and OP),
Not sure what advantage you are trying to show here. But considering that we are talking about pagination query here and order of records is important, your 2 queries will not always generate output in same order. Here is the test case:
SQL> select * from v$version ;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter pga
NAME TYPE VALUE
pga_aggregate_target big integer 103M
SQL> create table t nologging as select * from all_objects where 1 = 2 ;
Table created.
SQL> create index t_idx on t(last_ddl_time) nologging ;
Index created.
SQL> insert /*+ APPEND */ into t (owner, object_name, object_id, created, last_ddl_time) select owner, object_name, object_id, created, sysdate - dbms_random.value(1, 100) from all_objects order by dbms_random.random;
40617 rows created.
SQL> commit ;
Commit complete.
SQL> exec dbms_stats.gather_table_stats(user, 'T', cascade=>true);
PL/SQL procedure successfully completed.
SQL> select object_id, object_name, created from t, (select rid, rownum rn from (select rowid rid from t order by created desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
OBJECT_ID OBJECT_NAME CREATED
47686 ALL$OLAP2_JOIN_KEY_COLUMN_USES 28-JUL-2009 08:08:39
47672 ALL$OLAP2_CUBE_DIM_USES 28-JUL-2009 08:08:39
47681 ALL$OLAP2_CUBE_MEASURE_MAPS 28-JUL-2009 08:08:39
47682 ALL$OLAP2_FACT_LEVEL_USES 28-JUL-2009 08:08:39
47685 ALL$OLAP2_AGGREGATION_USES 28-JUL-2009 08:08:39
47692 ALL$OLAP2_CATALOGS 28-JUL-2009 08:08:39
47665 ALL$OLAPMR_FACTTBLKEYMAPS 28-JUL-2009 08:08:39
47688 ALL$OLAP2_DIM_LEVEL_ATTR_MAPS 28-JUL-2009 08:08:39
47689 ALL$OLAP2_DIM_LEVELS_KEYMAPS 28-JUL-2009 08:08:39
47669 ALL$OLAP9I2_HIER_DIMENSIONS 28-JUL-2009 08:08:39
47666 ALL$OLAP9I1_HIER_DIMENSIONS 28-JUL-2009 08:08:39
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc ;
OBJECT_ID OBJECT_NAME LAST_DDL_TIME
37534 com/sun/mail/smtp/SMTPMessage 06-FEB-2010 03:46:14
13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
42266 SI_GETCLRHSTGRFTR 06-FEB-2010 03:40:20
16695 /2940a364_RepIdDelegator_1_3 06-FEB-2010 03:38:17
36539 sun/io/ByteToCharMacHebrew 06-FEB-2010 03:28:57
26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
14044 /d29b81e1_OldHeaders 06-FEB-2010 03:12:12
36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
12920 /25f8f3a5_BasicSplitPaneUI 06-FEB-2010 03:11:06
15752 /2f494dce_JDWPThreadReference 06-FEB-2010 03:09:31
11 rows selected.
SQL> set autotrace traceonly
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc
2 ;
11 rows selected.
Execution Plan
Plan hash value: 44968669
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 91200 | 180 (2)| 00:00:03 |
| 1 | SORT ORDER BY | | 1200 | 91200 | 180 (2)| 00:00:03 |
|* 2 | HASH JOIN | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 3 | VIEW | | 1200 | 30000 | 98 (0)| 00:00:02 |
|* 4 | COUNT STOPKEY | | | | | |
| 5 | VIEW | | 40617 | 475K| 98 (0)| 00:00:02 |
| 6 | INDEX FULL SCAN DESCENDING| T_IDX | 40617 | 793K| 98 (0)| 00:00:02 |
| 7 | TABLE ACCESS FULL | T | 40617 | 2022K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("T".ROWID="T1"."RID")
3 - filter("RN">=1190)
4 - filter(ROWNUM<=1200)
Statistics
1 recursive calls
0 db block gets
348 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
11 rows selected.
Execution Plan
Plan hash value: 882605040
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 1 | VIEW | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 40617 | 1546K| 80 (2)| 00:00:01 |
|* 4 | SORT ORDER BY STOPKEY| | 40617 | 2062K| 80 (2)| 00:00:01 |
| 5 | TABLE ACCESS FULL | T | 40617 | 2062K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("RN">=1190)
2 - filter(ROWNUM<=1200)
4 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
343 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
11 rows selected.
Execution Plan
Plan hash value: 168880862
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 1 | HASH JOIN | | 1200 | 91200 | 179 (2)| 00:00:03 |
|* 2 | VIEW | | 1200 | 30000 | 98 (0)| 00:00:02 |
|* 3 | COUNT STOPKEY | | | | | |
| 4 | VIEW | | 40617 | 475K| 98 (0)| 00:00:02 |
| 5 | INDEX FULL SCAN DESCENDING| T_IDX | 40617 | 793K| 98 (0)| 00:00:02 |
| 6 | TABLE ACCESS FULL | T | 40617 | 2022K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("T".ROWID="T1"."RID")
2 - filter("RN">=1190)
3 - filter(ROWNUM<=1200)
Statistics
0 recursive calls
0 db block gets
349 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 order by last_ddl_time desc ;
11 rows selected.
Execution Plan
Plan hash value: 882605040
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 1 | VIEW | | 1200 | 62400 | 80 (2)| 00:00:01 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 40617 | 1546K| 80 (2)| 00:00:01 |
|* 4 | SORT ORDER BY STOPKEY| | 40617 | 2062K| 80 (2)| 00:00:01 |
| 5 | TABLE ACCESS FULL | T | 40617 | 2062K| 80 (2)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("RN">=1190)
2 - filter(ROWNUM<=1200)
4 - filter(ROWNUM<=1200)
Statistics
175 recursive calls
0 db block gets
388 consistent gets
0 physical reads
0 redo size
1063 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
0 sorts (disk)
11 rows processed
SQL> set autotrace off
SQL> spool offAs you will see, the join query here has to have an ORDER BY clause at the end to ensure that records are correctly sorted. You can not rely on optimizer choosing NESTED LOOP join method and, as above example shows, when optimizer chooses HASH JOIN, oracle is free to return rows in no particular order.
The query that does not involve join always returns rows in the desired order. Adding an ORDER BY does add a step in the plan for the query using join but does not affect the other query.
Maybe you are looking for
-
I've been charging and snycing with the cable and power adapter from the 4g iPod with my iPod touch. It seems fine but is there a chance that there will be a problem in the long run. I don't like using the cable that came with the touch because its t
-
I hove forgot my appe id security question. What can I do ?
I hove forgot my appe id security question. What can I do ?
-
TS3694 How can I get the passcode for resetting the iPad ?
I've been trying to reset my my iPad but I always get the wrong passcode.. Is there any way I can get it changed or sent to me?
-
Can't find serial number for iTunes
Can't find serial number for iTunes! I need it and I can't find it... Where do you find it in the new updated versions?? Help! Thanks
-
Why doesn't the buy button appear
I am trying to purchase music on itunes. the buy button does not appear. I am on the latest version of the itunes store