Home » RDBMS Server » Performance Tuning » create table statement with union
create table statement with union [message #469563] Thu, 05 August 2010 03:11 Go to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
Hi this statement is taking 1hr , can we reduce the timing?
CREATE TABLE DGT_ITEMEFFORTDATA (ENTERPRISEID, OWNERTYPE, OWNERID, SUPEROWNERTYPE, SUPEROWNERID, 
ITEMTYPE, ITEMID, STAGEID, USERID, DATEIDENTIFIED,
				DATECLOSED, ACTIVITYCODEID, PHASEID, RELEASEID, MONTHID, 
QUARTERID, INITIALEFFORT, BASELINEDEFFORT,
				ACTUALEFFORT, ITEMSTATUS, ALLOCATIONSTATUS, STAGESTATUS, 
OCCURANCETYPE, DSLPROJECTTYPE, METRICCALCRUNID,
				PLANNEDEFFORT,REMAININGEFFORT, ACTUAL_START_DATE, ACTUAL_END_DATE, 
BASELINED_START_DATE, BASELINED_END_DATE,
				CURBASE_START_DATE, CURBASE_END_DATE, PACKAGETYPE, PACKAGEID, 
PRACTICEID) NOLOGGING
				AS
				SELECT 	ENTERPRISEID, OWNERTYPE, OWNERID, SUPEROWNERTYPE, SUPEROWNERID, 
ITEMTYPE, ITEMID, STAGEID, USERID, DATEIDENTIFIED,
					DATECLOSED, ACTIVITYCODEID, PHASEID, RELEASEID, 
MONTHID, QUARTERID, INITIALEFFORT, BASELINEDEFFORT,
					ACTUALEFFORT, ITEMSTATUS, ALLOCATIONSTATUS, 
STAGESTATUS, OCCURANCETYPE, DSLPROJECTTYPE, METRICCALCRUNID,
					PLANNEDEFFORT,REMAININGEFFORT, ACTUAL_START_DATE, ACTUAL_END_DATE, 
BASELINED_START_DATE, 
BASELINED_END_DATE,
					CURBASE_START_DATE, CURBASE_END_DATE, PACKAGETYPE, 
PACKAGEID, PRACTICEID
				FROM DGT_ITEMEFFORTDATA_DAILY
				UNION ALL
				SELECT ENTERPRISEID, OWNERTYPE, OWNERID, SUPEROWNERTYPE, 
SUPEROWNERID, ITEMTYPE, ITEMID, STAGEID, USERID, DATEIDENTIFIED,
				DATECLOSED, ACTIVITYCODEID, PHASEID, RELEASEID, MONTHID, 
QUARTERID, INITIALEFFORT, BASELINEDEFFORT,
				ACTUALEFFORT, ITEMSTATUS, ALLOCATIONSTATUS, STAGESTATUS, 
OCCURANCETYPE, DSLPROJECTTYPE, METRICCALCRUNID,
				PLANNEDEFFORT,REMAININGEFFORT, ACTUAL_START_DATE, ACTUAL_END_DATE, 
BASELINED_START_DATE, BASELINED_END_DATE,
				CURBASE_START_DATE, CURBASE_END_DATE, PACKAGETYPE, 
PACKAGEID, PRACTICEID FROM DGT_ITEMEFFORTDATA_TEMP


This is the explain plan of the above query
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
| Id  | Operation          | Name                     | Rows  | Bytes | Cost (%C
--------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |                          |    11M|  4137M| 46149  (
|   1 |  UNION-ALL         |                          |       |       |
|   2 |   TABLE ACCESS FULL| DGT_ITEMEFFORTDATA_DAILY |  3455K|   428M| 14575
|   3 |   TABLE ACCESS FULL| DGT_ITEMEFFORTDATA_TEMP  |  7656K|  3709M| 31574
--------------------------------------------------------------------------------
Note
-----
   - 'PLAN_TABLE' is old version


This is the index details
1	DGT_ITEMEFFORTDATA_DAILY	HCLT_IDX_DGT_IFD	ITEMID	4
2	DGT_ITEMEFFORTDATA_DAILY	HCLT_IDX_DGT_IFD	ITEMTYPE	3
3	DGT_ITEMEFFORTDATA_DAILY	HCLT_IDX_DGT_IFD	OWNERID	2
4	DGT_ITEMEFFORTDATA_DAILY	HCLT_IDX_DGT_IFD	OWNERTYPE	1

There is no index on DGT_ITEMEFFORTDATA_TEMP table

Total no of records in DGT_ITEMEFFORTDATA_dialy:11176852
and DGT_ITEMEFFORTDATA_DAILY:3456786
and DGT_ITEMEFFORTDATA_TEMP :7720066

[Updated on: Thu, 05 August 2010 08:17] by Moderator

Report message to a moderator

Re: create table statement with union [message #469567 is a reply to message #469563] Thu, 05 August 2010 03:16 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And the question is?

Regards
Michel
Re: create table statement with union [message #469572 is a reply to message #469567] Thu, 05 August 2010 03:19 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
Hey man,

your response is very fast... great.

I missed the main thing that is the question, now i updated the information.
Re: create table statement with union [message #469573 is a reply to message #469572] Thu, 05 August 2010 03:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Do it in parallel (if your hardware supports it), decrease concurrent overload, buy faster disks and cpu.

Regards
Michel
Re: create table statement with union [message #469575 is a reply to message #469573] Thu, 05 August 2010 03:38 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
We have multiple cpu in our server, now please tell me how i can run it with parallel option.
Re: create table statement with union [message #469576 is a reply to message #469575] Thu, 05 August 2010 03:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Using PARALLEL option in CREATE TABLE and PARALLEL hint in SELECT.

Regards
Michel
Re: create table statement with union [message #469577 is a reply to message #469576] Thu, 05 August 2010 03:45 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
Thanks.

Could you pl tell me the exact hint considering my query or you need some more information about the server like how many cup's are there....
Re: create table statement with union [message #469578 is a reply to message #469577] Thu, 05 August 2010 03:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The hint is named PARALLEL, please see Database SQL Reference I will not copy and paste the documentation here.

Regards
Michel

[Updated on: Thu, 05 August 2010 03:46]

Report message to a moderator

Re: create table statement with union [message #469609 is a reply to message #469578] Thu, 05 August 2010 05:29 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
I got something like this

CREATE TABLE TEMP
PARALLEL 4 NOLOGGING
AS
SELECT /*+ PARALLEL (emp, 4) PARALLEL(detail,4) */
emp.emp_id emp_id
,deatil.house_id house_id
,detail.first_name first_name
,detail.last_name last_name
FROM
employee emp
,emp_details detail
WHERE
emp.emp_id = detail.emp_id;

bur one thing i am not able to understand what would be the degree in my case , like in above example it took 4.

This is my server configuration:
2 Intel Itanium 2 9100 series processors (1.67 GHz, 18 MB)
666 MT/s bus, CPU version A1
4 logical processors (2 per socket)
Re: create table statement with union [message #469616 is a reply to message #469609] Thu, 05 August 2010 05:45 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
It mainly depends on DISK subsystem before cpu.

Regards
Michel
Re: create table statement with union [message #469619 is a reply to message #469616] Thu, 05 August 2010 05:49 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
But again my question is same,what would be the degree of paralle in my case or is there any other way.
Re: create table statement with union [message #469620 is a reply to message #469619] Thu, 05 August 2010 05:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And my answer is the same one: "It mainly depends on DISK subsystem before cpu."

Regards
Michel
Re: create table statement with union [message #469634 is a reply to message #469620] Thu, 05 August 2010 06:17 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
ok.so u want more information,so that you can advice me about the exact value,or otherwsie i am not able to calculate the value.
Re: create table statement with union [message #469637 is a reply to message #469634] Thu, 05 August 2010 06:20 Go to previous messageGo to next message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could just try different values and see which gives the optimal result. I doubt you're going to be able to set it much higher than 4 anyway.
Re: create table statement with union [message #469638 is a reply to message #469634] Thu, 05 August 2010 06:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Yes I want at least information on disks: number, number of controlers, number of disk per controlers, structure (RAID or not), repartition of the tablespace files on the disks...
But the best way is for you ask your sysadmin what the performances of your disks.
If you can't have this information, the last step is to test, test, test, you could test many different values in the time this topic lasted.

Regards
Michel
Re: create table statement with union [message #469643 is a reply to message #469638] Thu, 05 August 2010 06:30 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
ok...so i start testing...but please advice me what should be the value and each time what would be the incrimental value.
Re: create table statement with union [message #469647 is a reply to message #469643] Thu, 05 August 2010 06:39 Go to previous messageGo to next message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
start with 2, increment by 1, I very much doubt you'll reach double digits.
Re: create table statement with union [message #469655 is a reply to message #469647] Thu, 05 August 2010 06:52 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
I got one thing to get the degree value..


Exec dbms_stats.gather_table_stats('my_user','my_tab', degree=>dbms_stats.auto_degree);

Now tell me whether it would be ok or not and if yes which column says me the value after gather the stats.
Re: create table statement with union [message #469678 is a reply to message #469655] Thu, 05 August 2010 07:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You completly miss the meaning of this.
Forget it, no use for your problem and do as we said instead of continuing to waste our time and yours.
You have all the information, now go to work.

Regards
Michel

[Updated on: Thu, 05 August 2010 07:57]

Report message to a moderator

Re: create table statement with union [message #469680 is a reply to message #469678] Thu, 05 August 2010 08:03 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
hey,

what u want to say.. i am not getting you.I tried on google and got something and then shared with you.
Re: create table statement with union [message #469685 is a reply to message #469680] Thu, 05 August 2010 08:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
I want to say that "Exec dbms_stats.gather_table_stats('my_user','my_tab', degree=>dbms_stats.auto_degree);" does not allow nothing about the degree you have to use in the query.
It just means Oracle will automatically the degree of parallelism to compute the statistics.
Nothing related to you.

Regards
Michel
Re: create table statement with union [message #469988 is a reply to message #469685] Fri, 06 August 2010 12:52 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
I tried with parallel option startted with degreee value 2 and incremented by 1 reached upto 10, but i did not get any time benifit, the normal and parallel option both are takig same time. So please advice me considering the query,whether i can optimise it without parallel option.
Re: create table statement with union [message #469990 is a reply to message #469988] Fri, 06 August 2010 12:53 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
No way but changing your hardware.

Regards
Michel
Re: create table statement with union [message #469995 is a reply to message #469990] Fri, 06 August 2010 13:10 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
ok. but is there no way to write the same query in differnet way.
Re: create table statement with union [message #469996 is a reply to message #469995] Fri, 06 August 2010 13:12 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Yes many and much faster but as I am a bastard I will not post it and prefer wasting my time trying to help you in another way.

Regards
Michel
Re: create table statement with union [message #470000 is a reply to message #469996] Fri, 06 August 2010 13:17 Go to previous messageGo to next message
prashant_ora
Messages: 196
Registered: July 2010
Senior Member
Hey Man,

Come on .. Do not be angry.. I am a fresher, and trying to optimise it, but not able to get any solution, thats why i posted this to forum.
Re: create table statement with union [message #470004 is a reply to message #470000] Fri, 06 August 2010 13:49 Go to previous messageGo to next message
Roachcoach
Messages: 1576
Registered: May 2010
Location: UK
Senior Member
His point is that your bottleneck is hardware (assuming no-one stuffed the SGA settings/other outlandish possibilities etc), as he said. If the bottleneck was the SQL structure, Michel wouldnt realistically tell you to upgrade the hardware (I think Wink )

Your query is tantamount to CTAS * FROM. There's not really anything to "optimise" on the query front. There's not even a where clause.

If running in parallel isn't helping, you're stuffed unless you change the hardware OR you do something with the query to make it more selective.
Re: create table statement with union [message #470005 is a reply to message #470000] Fri, 06 August 2010 13:50 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Maybe you are a fresher but this does imply you can't think.
1/ Do you think if there was a way to rewrite it I spent several days to find other ways without FIRST speaking about it?
2/ Do you think that there can be something simpler/smaller/more optimize to write a query that is the following one?
select * from t1 union all select * from t2

Regards
Michel
Previous Topic: create table statement
Next Topic: Table Partitioned with Primary key
Goto Forum:
  


Current Time: Mon Nov 25 15:10:30 CST 2024