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 advance
have 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
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 -
How to get SQL script for generating table, constraint, indexes?
I'd like to get from somewhere Oracle tool for generating simple SQL script for generating table, indexes, constraint (like Toad) and it has to be Oracle tool but not Designer.
Can someone give me some edvice?
Thanks!
m.I'd like to get from somewhere Oracle tool for
generating simple SQL script for generating table,
indexes, constraint (like Toad) and it has to be
Oracle tool but not Designer.
SQL Developer is similar to Toad and is an Oracle tool.
http://www.oracle.com/technology/products/database/sql_developer/index.html -
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 -
Plsql coding for multiplication table
hai i need plsql coding for multiplication table can any one plzzzz.....
SELECT AVBELN AFKDAT AVTWEG ASPART AWAERK AKURRF AKUNAG AKNUMV
BPOSNR BFKIMG BNETWR BMATNR
DBEGRU ELABOR E~MATKL
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM VBRK AS A INNER JOIN VBRP AS B
ON AVBELN EQ BVBELN
INNER JOIN J_1IEXCHDR AS C
ON AVBELN EQ CRDOC
INNER JOIN KNVV AS D
ON DKUNNR EQ AKUNAG AND
DVKORG EQ AVKORG AND
DSPART EQ ASPART AND
D~BEGRU NE SPACE
INNER JOIN MARA AS E
ON EMATNR EQ BMATNR
WHERE A~FKDAT IN S_FKDAT AND
A~FKART EQ 'F2' AND
A~VTWEG IN S_VTWEG AND
A~SPART IN S_SPART AND
A~KUNAG IN S_KUNAG AND
A~FKSTO NE 'X' AND
B~WERKS IN S_WERKS AND
C~TRNTYP = 'DLFC' AND
E~LABOR IN S_LABOR AND
C~SRGRP IN ('01','02','03','31','32','33','41','42','43',
'81','82','83','95','55','45', '48') AND
B~MATNR IN S_MATNR AND
D~BEGRU IN S_BEGRU AND
E~MATKL IN S_MATKL.
but my suggestion not to use more than 2 table in inner join it will affect in performance use for all entries instead of join.
regards
shiba dutta -
BAPI coding for CATSDB TABLE i.e Timesheet DB
BAPI coding for CATSDB TABLE i.e Timesheet DB
Points will be rewarded,
Thank you,
Jagrut BharatKumar ShuklaHi Srikhar
use these bapis
BAPI_BPCONTACT_CHANGE BAPI
BAPI_BPCONTACT_CREATEFROMDATA BAPI .... BAPI_CUSTOMERCONTRACT_CHANGE
BAPI_CTRACCONTRACTACCOUNT_CH1
reward points to all helpful answers
kiran.M -
Sample coding for multiple table join
Hi,
i need a sample coding for multiple table join. can anyone help me out.
regards
GokulSELECT AVBELN AFKDAT AVTWEG ASPART AWAERK AKURRF AKUNAG AKNUMV
BPOSNR BFKIMG BNETWR BMATNR
DBEGRU ELABOR E~MATKL
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM VBRK AS A INNER JOIN VBRP AS B
ON AVBELN EQ BVBELN
INNER JOIN J_1IEXCHDR AS C
ON AVBELN EQ CRDOC
INNER JOIN KNVV AS D
ON DKUNNR EQ AKUNAG AND
DVKORG EQ AVKORG AND
DSPART EQ ASPART AND
D~BEGRU NE SPACE
INNER JOIN MARA AS E
ON EMATNR EQ BMATNR
WHERE A~FKDAT IN S_FKDAT AND
A~FKART EQ 'F2' AND
A~VTWEG IN S_VTWEG AND
A~SPART IN S_SPART AND
A~KUNAG IN S_KUNAG AND
A~FKSTO NE 'X' AND
B~WERKS IN S_WERKS AND
C~TRNTYP = 'DLFC' AND
E~LABOR IN S_LABOR AND
C~SRGRP IN ('01','02','03','31','32','33','41','42','43',
'81','82','83','95','55','45', '48') AND
B~MATNR IN S_MATNR AND
D~BEGRU IN S_BEGRU AND
E~MATKL IN S_MATKL.
but my suggestion not to use more than 2 table in inner join it will affect in performance use for all entries instead of join.
regards
shiba dutta -
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;
/ -
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. -
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 -
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?
-
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 -
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. -
hi there..i need ur helps
Here are my tables n column name for each tables
a) rep_arrngt
Name
REP_ARRNGT_ID
REP_ARRNGT_DESC
REP_ARRNGT_TYPE
ACCT_CAT
DEF_INDUSTRY_CODE
MEDIA_ID
LANGUAGE_ID
CURRENCY
PAGE_ID
b) bci_rep_arrng
Name
REP_ARRNGT_ID
BCI
SUB_SUM_CODE
DP_SUB_SUM_CODE
c) acct_rep_arrngt_link
Name
ACCT_NO
REP_ARRNGT_ID
DOC_TYPE
LAST_BILL_DATE
BILL_FREQUENCY
SCALING
EFF_FROM_DATE
EFF_TO_DATE
MEDIA_ID
Actually, i want to get the unique value for sub_sum_code according to the bci..
i already use join tables n here is my sql statement :
SELECT T1.SUB_SUM_CODE,T1.BCI,T1.REP_ARRNGT_ID,T2.REP_ARRNGT_ID,T3.REP_ARRNGT_ID FROM BCI_REP_ARRNG T1, REP_ARRNGT T2, ACCT_REP_ARRNGT_LINK T3 WHERE T1.REP_ARRNGT_ID=T2.REP_ARRNGT_ID AND T2.REP_ARRNGT_ID=T3.REP_ARRNGT_ID AND BCI='TTA00F06'
n my results is :
SUB_SUM_CODE BCI REP_ARRNGT_ID
TBGSR TTA00F06 R1
TBGSR TTA00F06 R1
TBGSR TTA00F06 R1
TBGSR TTA00F06 R1
I get the repeated results for sub_sum_code..
so, what i need to do if i want only 1 row results like this :
[u]SUB_SUM_CODE BCI REP_ARRNGT_ID
TBGSR TTA00F06 R1
i try to use group by, but i get the error..plz help meIf you only want "to get the unique value for sub_sum_code according to the bci" then why are you joining the tables in the first place? Not knowing PKs etc you could just use DISTINCT in your select statement.
SELECT DISTINCT T1.SUB_SUM_CODE,
T1.BCI
FROM BCI_REP_ARRNG T1
AND BCI='TTA00F06'
Maybe you are looking for
-
My Sony Xplod car stereo no longer operates my iphone.
I bought a Sony Xplod car stereo about a year ago. It's advertised to dock with the Iphone and for a year has done exactly that. Since the last iphone update though it no longer works correctly. I'm certain it's the iphone software not the stereo as
-
IPrint app for iOS fails to print photos in colour
We are running the latest build of the iPrint Appliance (Version: 1.0.1.69 Patch 1) and cannot get the iPrint app for iOS to print photos in colour. I suspect that this is a problem with the internal renderer and JPG files. Printing a PDF, DOC or DOC
-
How to avoid the"Saving iTunes Library" dialog
I have been experience this issue for a couple of weeks now, the only information that i found online regarding this was related to an antivirus, but i never used any ativirus. if there any other reason why itunes is doing this? My library is only 38
-
I want to teach Siri new words. Every time I say Tarot she's types in Carol
I write books on the tarot and astrology, and Siri can't seem to understand me when I typed the word Tarot in text messages, no matter how many times I try to pronounce it. I tried to the technique of teaching her the word the contacts, but that's no
-
Pls help.JSP: I could not store Chinese characters into files.
Hi experts, I have this problem of cant store chinese characters into files(eg. .txt and .properties). I am adding these chinese text through a JSP website form....After i key in chinese characters in the textboxes in the website and sumbit the resul