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.com
I hope it will be only current partition which has teh stale statistics will be gathered the stastics instead of full table.
Anil Malkai
Similar Messages
-
Hi All,
In 10g, Oracle automatically collects the statistics between 10 to 6 night window. I am just curious about what estimate_percent it takes for this. I mean when we do manual stats gathering by following command, it takes 20 percent for estimation:
exec dbms_stats.gather_table_stats(ownname=>'scott',estimate_percent=>20, method_opt=>'FOR ALL INDEXED COLUMNS SIZE 1',degree=>7, cascade=>true,granularity=>'all');
I am gathering the stats by above command for some of my schemas. Now, I want to rely on auto stats gathering feature of Oracle 10g. So I want to know the estimate_percent taken by Oracle.
Thanks,
Api14.3.1.1 Statistics Gathering Using Sampling
The statistics-gathering operations can utilize sampling to estimate statistics. Sampling is an important technique for gathering statistics. Gathering statistics without sampling requires full table scans and sorts of entire tables. Sampling minimizes the resources necessary to gather statistics.
Sampling is specified using the ESTIMATE_PERCENT argument to the DBMS_STATS procedures. While the sampling percentage can be set to any value, Oracle Corporation recommends setting the ESTIMATE_PERCENT parameter of the DBMS_STATS gathering procedures to DBMS_STATS.AUTO_SAMPLE_SIZE to maximize performance gains while achieving necessary statistical accuracy. AUTO_SAMPLE_SIZE lets Oracle determine the best sample size necessary for good statistics, based on the statistical property of the object. Because each type of statistics has different requirements, the size of the actual sample taken may not be the same across the table, columns, or indexes. For example, to collect table and column statistics for all tables in the OE schema with auto-sampling, you could use:
EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS('OE',DBMS_STATS.AUTO_SAMPLE_SIZE);
When the ESTIMATE_PERCENT parameter is manually specified, the DBMS_STATS gathering procedures may automatically increase the sampling percentage if the specified percentage did not produce a large enough sample. This ensures the stability of the estimated values by reducing fluctuations. -
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 -
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 -
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 -
Gather Stats on Newly Partitioned Table
I partitioned an existing table containing 92 million rows. The method was using dbms_redefinition, whereby I started the redef and then added the indexes and constraints last. After partitioning, I did not gather stats on any of the partitions that were created and I did not analyze any of the indexes. Then I loaded an additional 4 million records into on of the partitions of the newly partitioned table. I ran dbms gather stats on this particular partition and it took over 15 hours. Normally it only takes 4 hours to run dbms gather stats on the individual partitions, so I stopped it after 15 hours. When I monitored it while it was running, it looked like it was taking a really long time gathering stats on the indexes. Is this normal for a newly partitioned table? Is there something I can to prevent it from taking so long when I run gather stats? Oracle Version 10.2.0.4
-- Gather PARTITION Statistics
SYS.DBMS_STATS.gather_table_stats(ownname => upper(v_table_owner), tabname => upper(v_table_name),
partname =>v_table_partition_name, estimate_percent => 20, cascade=> FALSE,granularity => 'PARTITION');
-- Gather GLOBAL INDEX Statistics
for i in (select * from sys.dba_indexes where table_owner = upper(v_table_owner)
and table_name = upper(v_table_name) and partitioned = 'NO'
order by index_name)
loop
SYS.DBMS_STATS.gather_index_stats(ownname => upper(v_table_owner), indname => i.index_name,
estimate_percent => 20, degree => NULL);
end loop;
-- Gather SUB-PARTITION Statistics
SYS.DBMS_STATS.gather_table_stats(ownname => upper(v_table_owner), tabname => upper(v_table_name),
partname =>v_table_subpartition_name, estimate_percent => 20, cascade=> TRUE,granularity => 'ALL'); -
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;
/ -
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. -
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 -
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. -
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. -
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 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; -
UPDATE Statement executing for whole table even when WHERE Clause is presen
Hi Friends,
I have a problem in a stored procedure where i have written an update statement with a where clause. At a time only one row should get updated depending upon unique identifier in where clause.
But whats happening is that Update statement is getting executed for all the rows in the table neglecting the WHERE clause. I am not getting the clue as to why this is happening. Here is the stored Procedure And the update statement is in BOLD :-
CREATE OR REPLACE PROCEDURE MDMADM.proc_MDM_InsertCntryDetails
CntryMasterCode IN VARCHAR2,
CntryName IN VARCHAR2,
MDMUser IN VARCHAR2,
Exist IN INTEGER,
status IN VARCHAR2,
Inserted_By IN VARCHAR2 DEFAULT NULL,
Modified_By IN VARCHAR2 DEFAULT NULL,
Mdm_Code IN NUMBER DEFAULT 0,
Action IN VARCHAR2 DEFAULT 'add',
XGenAttNames IN VARCHAR2 DEFAULT NULL,
XGenAttValues IN VARCHAR2 DEFAULT NULL,
MirusAttNames IN VARCHAR2 DEFAULT NULL,
MirusAttValues IN VARCHAR2 DEFAULT NULL,
GenisysAttNames IN VARCHAR2 DEFAULT NULL,
GenisysAttValues IN VARCHAR2 DEFAULT NULL,
XGenModify IN VARCHAR2 DEFAULT NULL,
MirusModify IN VARCHAR2 DEFAULT NULL,
GenisysModify IN VARCHAR2 DEFAULT NULL
IS
strSQLXGen VARCHAR(1000);
strSQLMirus VARCHAR(1000);
strSQLGenisys VARCHAR(1000);
nMaxMDMCode INTEGER;
ifExist INTEGER;
NAME: proc_MDM_InsertCntryDetails
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 7/3/2009 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: proc_MDM_InsertCntryDetails
Sysdate: 7/3/2009
Date and Time: 7/3/2009, 7:11:20 PM, and 7/3/2009 7:11:20 PM
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
BEGIN
SELECT COUNT(*) INTO ifExist FROM MDM_COUNTRY_MASTER;
IF ifExist = 0 THEN
SELECT 1 INTO nMaxMDMCode FROM DUAL;
ELSE
SELECT MAX(MDM_CODE)+1 INTO nMaxMDMCode FROM MDM_COUNTRY_MASTER;
END IF;
IF Action='add' THEN
INSERT INTO MDM_COUNTRY_MASTER(MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,DAT_INSERTED_BY)
VALUES(nMaxMDMCode,CntryMasterCode,CntryName,MDMUser,Exist,status,Action,SYSDATE,Inserted_By);
strSQLXGen := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || XGenAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || nMaxMDMCode || ',' || '''' || 'XGen' || '''' || ',1,' || XGenAttValues || ',' || '''' || Inserted_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLXGen;
strSQLMirus := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || MirusAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || nMaxMDMCode || ',' || '''' || 'Mirus' || '''' || ',2,' || MirusAttValues || ',' || '''' || Inserted_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLMirus;
strSQLGenisys := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || GenisysAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || nMaxMDMCode || ',' || '''' || 'Genisys' || '''' || ',3,' || GenisysAttValues || ',' || '''' || Inserted_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLGenisys;
ELSE
UPDATE MDM_COUNTRY_MASTER
SET MDM_DESCRIPTION=CntryName,DAT_MODIFIED_BY=Modified_By,DAT_MODIFY_DATE=SYSDATE,
MDM_USER=MDMUser,MDM_ACTION=Action,MDM_STATUS=status,MDM_EXIST=Exist WHERE MDM_CODE=Mdm_Code;
SELECT COUNT(*) INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE=1 AND MDM_CODE=Mdm_Code ;
IF ifExist = 0 THEN
strSQLXGen := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || XGenAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || Mdm_Code || ',' || '''' || 'XGen' || '''' || ',1,' || XGenAttValues || ',' || '''' || Modified_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLXGen ;
ELSE
strSQLXGen := 'UPDATE MDM_COUNTRY_MAPPING SET ' || XGenModify || ',DAT_MODIFY_DATE=SYSDATE,DAT_MODIFIED_BY=' || '''' || Modified_By || '''' || ' WHERE MDM_CODE=' || Mdm_Code || ' and SYSTEM_CODE=1' ;
EXECUTE IMMEDIATE strSQLXGen ;
END IF;
SELECT COUNT(*) INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE=2 AND MDM_CODE=Mdm_Code ;
IF ifExist = 0 THEN
strSQLMirus := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || MirusAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || Mdm_Code || ',' || '''' || 'Mirus' || '''' || ',2,' || MirusAttValues || ',' || '''' || Modified_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLMirus ;
ELSE
strSQLMirus := 'UPDATE MDM_COUNTRY_MAPPING SET ' || MirusModify || ',DAT_MODIFY_DATE=SYSDATE,DAT_MODIFIED_BY=' || '''' || Modified_By || '''' || ' WHERE MDM_CODE=' || Mdm_Code || ' and SYSTEM_CODE=2' ;
EXECUTE IMMEDIATE strSQLMirus ;
END IF;
SELECT COUNT(*) INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE=3 AND MDM_CODE=Mdm_Code;
IF ifExist = 0 THEN
strSQLGenisys := 'INSERT INTO MDM_COUNTRY_MAPPING(MDM_CODE,SYSTEM_NAME,SYSTEM_CODE,' || GenisysAttNames || ',DAT_INSERTED_BY,DAT_INSERT_DATE) ' ||
'VALUES(' || Mdm_Code || ',' || '''' || 'Genisys' || '''' || ',3,' || GenisysAttValues || ',' || '''' || Modified_By || '''' || ',SYSDATE)';
EXECUTE IMMEDIATE strSQLGenisys ;
ELSE
strSQLGenisys := 'UPDATE MDM_COUNTRY_MAPPING SET ' || GenisysModify || ',DAT_MODIFY_DATE=SYSDATE,DAT_MODIFIED_BY=' || '''' || Modified_By || '''' || ' WHERE MDM_CODE=' || Mdm_Code || ' and SYSTEM_CODE=3' ;
EXECUTE IMMEDIATE strSQLGenisys ;
END IF;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END proc_MDM_InsertCntryDetails;
ThanksIt might be helpful to search this forum and google for PL/SQL (variables, stored procs, etc) naming standards. There are quite a few out there and you can choose one that works for you.
As an example, a lot of standards adopt naming prefixes, ie v_ for VARCHAR variable, n_ for NUMBER variable, pv_ for paramater VARCHAR, etc.
Maybe you are looking for
-
File Attachments are blank - PDF IO Exception
Hi Everyone, I have a Web Dynpro Java Application form that when submitted generates an Adobe Interactive form along with any attachments and starts a guided procedure. Today I'm experiencing a random error (see below), if I preview the Adobe form be
-
I can't get this to work! (hard to describe in topic) (please read)
My other class, DivideGenes, is supposed to divide the genes created in Genes in half (to create a sperm cell). I do this by 1. copying the array 2. finding random indexes in the array 3. coppying the values of the random indexes to a different array
-
How to see the peak values in a chart?
I have the following situation: I am applying the FFt to an acceleration signal. In the FFT-peak graph I see different peak frequencies. However I would like to know how much are those peak values and either display them in the chart on top of the pe
-
I am unable to sign in for adobe photoshop elements 10. Any suggestions?
Every time I try to sign in I get a message Photoshop.com is currently unavailable. Try again later. This has been going on for months. Does anyone know what I can do to fix this?
-
Feature Request: Change Style - Style Set (word like)
I'm learning to use pages and there is a feature in word that I miss a lot. It's the Change Style - Style Set I want to change all the styles of my document, using the templates that I have installed in my machine, in a coherent way. In word I can do