|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
The bigger problem... tunning!!
Hi everyone...
Actually i dont know how to tune a procedure... i am giving u all the data if u can please help me.... Function: create or replace function dump_data( p_query in varchar2, p_dir in varchar2 , p_filename in varchar2 ) return number is l_output utl_file.file_type; l_theCursor integer default dbms_sql.open_cursor; l_columnValue varchar2(2000); l_status integer; l_colCnt number default 0; l_separator varchar2(10) default ''; l_cnt number default 0; begin l_output := utl_file.fopen( p_dir, p_filename, 'w' ); dbms_sql.parse( l_theCursor, p_query, dbms_sql.native ); for i in 1 .. 255 loop begin dbms_sql.define_column( l_theCursor, i, l_columnValue, 2000 ); l_colCnt := i; exception when others then if ( sqlcode = -1007 ) then exit; else raise; end if; end; end loop; dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 ); l_status := dbms_sql.execute(l_theCursor); loop exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 ); l_separator := ''; for i in 1 .. l_colCnt loop dbms_sql.column_value( l_theCursor, i, l_columnValue ); utl_file.put( l_output, l_separator || l_columnValue ); end loop; utl_file.new_line( l_output ); l_cnt := l_cnt+1; end loop; dbms_sql.close_cursor(l_theCursor); utl_file.fclose( l_output ); return l_cnt; end dump_data; Procedure create or replace procedure MEXICO_NAFTA_CERTIFICATE_EXT as l_rows number; begin l_rows := dump_data( 'select c1.certificate_nbr, c2.part_nbr as part171, c2.inactive_ind, c2.hts_cde, c2.originating_ind, c3.iso_country_cde, c2.basis_cde, c2.producer_cde, c2.cert_cde, c2.regional_value_content_cde, c2.part_nbr, c1.effective_dte from certificates c1 , certificate_parts c2 ,displayed_countries_of_origin c3 where c1.certificate_nbr=c2.certificate_nbr and c2.certificate_nbr=c3.certificate_nbr', ',' '/d014/oradata/temp', 'MEXICO_NAFTA_CERTIFICATE_EXT.txt' ); dbms_output.put_line( to_char(l_rows) || ' rows extracted to ascii file' ); end; Both the function and procedures got executed without errors but its taking really long time to get output... it have to load almost 99842 rows in the text file... i have to tune that query and i really dont know how to... explain plan of the query: PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 1014373765 -------------------------------------------------------------------------------- ----------------------------- | Id | Operation | Name | Rows | Bytes |Tem pSpc| Cost (%CPU)| Time | -------------------------------------------------------------------------------- ----------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 18M| 813M| | 7318 (3)| 00:01:43 | |* 1 | HASH JOIN | | 18M| 813M| 16M| 7318 (3)| 00:01:43 | | 2 | TABLE ACCESS FULL | DISPLAYED_COUNTRIES_OF_ORIGIN | 884K| 6047K| | 394 (4)| 00:00:06 | |* 3 | HASH JOIN | | 733K| 27M| 2 352K| 4554 (1)| 00:01:04 | PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 4 | TABLE ACCESS FULL| CERTIFICATES | 99841 | 1170K| | 657 (1)| 00:00:10 | | 5 | TABLE ACCESS FULL| CERTIFICATE_PARTS | 733K| 19M| | 2592 (2)| 00:00:37 | -------------------------------------------------------------------------------- ----------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("C2"."CERTIFICATE_NBR"="C3"."CERTIFICATE_NBR") 3 - access("C1"."CERTIFICATE_NBR"="C2"."CERTIFICATE_NBR") 18 rows selected. it should be 99848 rows selected not 18 and i dont know why.... i am really not understaing... please some one help me.... Thanking You Bhagya |
|
#2
|
||||
|
||||
|
Would you mind reading this ?
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
|||
|
|||
|
I read it.... and i understood it.... i have just started as an developer and i am really unable to figure out... i already had my first warning yesturday form my DB saying that my processes have hang up the database.... thats why i need some help.... plese help me if u can.....day by day i am getting near to losing my job...
|
|
#4
|
||||
|
||||
|
Quote:
Quote:
|
|
#5
|
|||
|
|||
|
Ok.... The actual task is to get few columns(12) form 3 tables and extract them to a text file....i have tried and used the concept of UTIL File.... the above code is about it.... but i dint work properly.... can u help me now...
bhagya |
|
#6
|
||||
|
||||
|
Quote:
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > The bigger problem... tunning!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|