Monday, August 31, 2009

Colours To The Shag Bands

Copy Windows data in LogMiner

The request was

When the database can keep the same name and same SID is as easy as copying datafiles, redo, ControlFiles ORA files and directories on the same original on a machine with an Oracle server installed

*

.

* Of course, same OS platform, version and release of Oracle.

This example assumes that you have the possibility of doing a cold backup of the database. Preliminary Steps

(recommended) :
- Backup cold, hot backup, export, Transport Tablespaces, backup, backup, backup of everything. - Reduction in size of the datafiles. (Tom Kyte has a fabulous script for it). Again backup.
Steps: 1 .-


Cold Backup of original DB

2 .- generation of new DB for pfile 3 .- Edit the pfile to replace: control_files, DB_NAME, and _DUMP_DEST folders. .. 4 .- Define the new ORACLE_SID
5 .- Create the new service.
6 .- Creation
password file (if the pfile is REMOTE_LOGIN_PASSWORDFILE = exclusive) 7 .- sqlplus as SYSDBA connection
8 .- Startup the instance and creating the SPFILE parameter file Backup
9 .- the controlfile to trace the original DB
10 .- Recreation controlfile to clause
SET NAME. 11 .- Open the database with OPEN RESETLOGS mode

.




1 .- Cold Backup of the original DB.
Restore backup on new location.
- Implement the outcome of the next sentence and script.
- NOTE: Beware of duplicate file names. ------------------------------------------------- ------------ select 'Immediate shutdown;' from dual union all

select 'host copy' 2 .- Generation pfile for the new database

SQL> create pfile = '? \\ Admin \\ sid \\ pfile \\ inittest.ora' from spfile;
file created.



3 .- Edit the pfile to replace: control_files, DB_NAME, and folders _DUMP_DEST ...





4 .- Define the new ORACLE_SID


c: \\> set ORACLE_SID = test




5 .- Create the new service.


c: \\> oradim-NEW-SRVC-StartMode OracleServicetest self


6 .- Creating the password file


c: \\> orapwd file = C: \\ orant \\ ora92 \\ database \\ PWDtest.ora password = xxxxxxxxx


7 .- sqlplus as SYSDBA connection


C: \\> sqlplus SQL * Plus: Release 9.2.0.6.0 - Production on Fri July 29 16:41:22 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Enter the user name: sys / xxxxxxxxxx
as sysdba Connected to an idle instance.


8 .- Startup the instance and file creation parameters


SPFILE SQL> STARTUP PFILE NOMOUNT = 'C: \\ DIRECTORIO_DESTINO \\ inittest.ora'
ORACLE Instance initiated. Total System Global Area 1074866044 bytes Fixed Size 456572 bytes

Variable Size 905969664 bytes Database Buffers 167772160 bytes

Redo Buffers 667648 bytes
SQL> create spfile from pfile = 'C: \\ DIRECTORIO_DESTINO \\ inittest.ora';
File created.



9 .- PROD backup of controlfile to trace.


SQL> alter database backup controlfile to trace;

Database altered.



10 .- From the trace control file. Recreation
controlfile with SET NAME to the new name.


CREATE CONTROLFILE SET DATABASE "TEST" RESETLOGS
NOARCHIVELOG REUSE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES
MaxInstance 1 133 453
MAXLOGHISTORY

LOGFILE GROUP 2 'C: \\ DATA \\ TEST \\ REDO \\ REDO02.LOG' SIZE 100M ,
GROUP 3 'C: \\ DATA \\ TEST \\ REDO \\ REDO03.LOG' SIZE 100M, GROUP 4
'C: \\ DATA \\ TEST \\ REDO \\ REDO04.LOG' SIZE 150M, GROUP 5
'C: \\ DATA \\ TEST \\ REDO \\ REDO05.LOG 'SIZE 150M, GROUP 6
' C: \\ DATA \\ TEST \\ REDO \\ REDO06.LOG ' SIZE 200M - STANDBY LOGFILE DATAFILE

(... files ...)

'C: \\ DATA \\ TEST \\ SYSTEM \\ SYSTEM01.DBF'
'C: \\ DATA \\ TEST \\ DATA \\ DATA01.DBF' CHARACTER SET WE8MSWIN1252

;
Control file created.


11 .- Open the database with OPEN RESETLOGS mode.

SQL> alter database open RESETLOGS;

Database altered.




12 .- Verification.


SQL> select instance_name from v $ instance;
INSTANCE_NAME
----------------

test SQL> select name from v $ database;


NAME --------- TEST


SQL> select status from v $ thread;

OPEN STATUS ------




12 .- Shutdown and Open database.


SQL> shutdown Immediate; Database closed. Database removed. ORACLE Instance
closed.

SQL> startup ORACLE instance started
.

Total System Global Area 1074866044 bytes Fixed Size 456572 bytes

Variable Size 905969664 bytes Database Buffers 167772160 bytes

Redo Buffers
667648 bytes Database mounted.
open database.



Where To Find Red Velvet Cake In Toronto Area









On occasion I needed to recover a transaction COMMIT validated, but unwanted or erroneous. Here's an example:
- user deletes a row.
- by accident.
- Do not know what line it is, but 'something' says "deleted record."
-
(... deleted and validated)
.
- No idea what was the row data.
- Neither he, nor anyone.
- Since then, the row X has disappeared without trace.

With variations, this case is quite frequent, and if the user has erased the record is fast enough, there is a possibility of recovering the lost data.

Generally, all conventional transaction information processed through the areas of redo log. In these files is all the information for the new change. Oracle bases its entire business in the proper functioning of the redo log record and, therefore, in this area only basic physical data stores to redo the operation. Therefore, no information is stored on the previous values.

Which it does in the area of \u200b\u200brollback and rollback management also happens to redo!.
Oracle has a package, the LOG MINER that tracks the redo logs (online and archived) along with the rollback information also available in them. Once you run the package that creates the object dictionary file, Oracle is able to interpret and display information such redologs as valid as the generated SQL and SQL opposite to "repair" action.






SQL> connect / as sysdba Connected
.
SQL> show parameters utl NAME TYPE VALUE


------------------------------------ ------------------------------ -----------

utl_file_dir string c: \\ oraclefiles


SQL> exec
DBMS_LOGMNR_D.BUILD (DICTIONARY_FILENAME => 'dictionary.ora' DICTIONARY_LOCATION => 'c: \\ oraclefiles');
PL / SQL procedure successfully completed.
SQL> select member from v $ logfile;
----------------------------------- MEMBER --------------------------------------------- C: \\ ORACLE \\ oradata \\ ORCL \\ REDO04A.LOG C: \\ ORACLE \\ oradata \\ ORCL \\ REDO04B.LOG C: \\ ORACLE \\ oradata \\ ORCL \\ REDO05A.LOG C: \\ ORACLE \\ oradata \\ ORCL \\ REDO05B.LOG C: \\ ORACLE \\ oradata \\ ORCL \\ REDO06A.LOG
C: \\ ORACLE \\ oradata \\ ORCL \\ REDO06B.LOG
6 rows selected.

SQL> exec
DBMS_LOGMNR.add_logfile ('C: \\ ORACLE \\ oradata \\ ORCL \\ REDO04A.LOG');


PL / SQL procedure successfully completed.
SQL> exec
DBMS_LOGMNR.add_logfile ('C: \\ ORACLE \\ oradata \\ ORCL \\ REDO05A.LOG');

PL / SQL procedure successfully completed.
SQL> exec
DBMS_LOGMNR.add_logfile ('C: \\ ORACLE \\ oradata \\ ORCL \\ REDO06A.LOG');


PL / SQL procedure successfully completed.

SQL> EXECUTE
DBMS_LOGMNR.START_LOGMNR (DICTFILENAME => 'c: \\ oraclefiles \\ dictionary.ora');


PL / SQL procedure successfully completed.

SQL> set pages 100
SQL> set lines 120
SQL> column sql_redo
format a50 SQL> column sql_undo
format a50 SQL> select sql_redo, sql_undo from v $ logmnr_contents
WHERE rownum


SQL_REDO SQL_UNDO -------------------------------------------------- --------------------------------------------------
insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX", "Amount MIN" Amount SUM "= '170, 01 ' and "Amount COUNT" = '1 '
, "Amount AVG", "City", "Country", "Age Range", "Sex" and "Amount MAX' = '170, 01 'and' Amount MIN" = '
, "Flight Details") values \u200b\u200b('170, 01 ', '1', '170, 01 ', '1 170.01' and 'Amount AVG = '170, 01' and 'City' 70.01 ', '170, 01', 'Madeira', 'Portugal', 'Over 5 =' Madeira 'and "Country" =' Portugal 'and' Eda Range 0 to ± os', 'Woman', 'VUELO52149' ) d '=' Over 50 a ± os 'and' Sex '=' Male 'and
"Flight Details" =' VUELO52149 'and ROWID =' AAALV
mAAPAAAAn8AAA ';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where " and SUM", "Amount COUNT", "Amount MAX", "Amount MIN" Amount SUM " = '112, 95 'and' Amount COUNT "= '1 '," Amount AVG "," City "," Country "," Age Range "," Sex "and" Amount MAX' = '112, 95 'and "Amount MIN" = '
, "Flight Details") values \u200b\u200b('112, 95', '1 ', '112, 95', '1 112.95 'and' Amount AVG = '112, 95 'and " City "
12.95 ', '112, 95', 'Madeira', 'Portugal', 'Over 5 =' Madeira 'and" Country " = 'Portugal' and 'Eda
Range 0 to ± os',' Woman ',' VUELO52206 ') d' = 'Over 50 a ± os' and' Sex '=' Male 'and
"Flight Details" = 'VUELO52206' and ROWID = 'AAALV
mAAPAAAAn8AAB';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX "," Amount MIN "Amount SUM" = '123, 29 'and' Amount COUNT "= '1 '
," Amount AVG "," City "," Country "," Age Range "," Sex "and" Amount MAX = '123, 29 'and' Amount MIN "= '," Flight Details ") values \u200b\u200b('123, 29', '1 ', '123, 29', '1 123.29 'and' Amount AVG" = ' 123.29 "and" City " 23.29 ', '123, 29', 'Madeira', 'Portugal', 'Over 5 =' Madeira 'and" Country "=' Portugal 'and' Range Eda <10;
0 a ± os', 'Woman', 'VUELO52331') d '=' Over 50 a ± os' and 'Sex' = 'Male' and
"Flight Details" = 'VUELO52331' and ROWID = 'AAALV mAAPAAAAn8AAC ';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from "DISCOVERER9I." EUL5_MV101651 "where"
and SUM "," Amount COUNT "," Amount MAX "," Amount MIN "Amount SUM" = '178, 55 'and' Amount COUNT "= '1 '
, "Amount AVG", "City", "Country", "Age Range", "Sex" and "Amount MAX = '178, 55 'and' Amount MIN" = '
, "Flight Details") values \u200b\u200b('178 , 55 ', '1', '178, 55 ', '1 178.55' and 'Amount AVG = '178, 55' and 'City'
78.55 ', '178, 55', 'Madeira' , 'Portugal', 'Over 5 =' Madeira 'and "Country" =' Portugal 'and' Eda
Range 0 to ± os', 'Woman', 'VUELO52419') d '=' Over 50 to ± os' and "Sex" = 'Male' and
"Flight Details" = 'VUELO52419' and ROWID = 'AAALV
mAAPAAAAn8AAD';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX", "Amount MIN" Amount SUM "= '107, 36 'and' Amount COUNT" = '1 '
, "Amount AVG", "City" "Country", "Age Range", "Sex" and "Amount MAX = '107, 36 'and' Amount MIN" = '
, "Flight Details") values \u200b\u200b('107, 36', '1 ',' 107.36 ', '1 107.36' and 'Amount AVG = '107, 36 'and' City '
07.36', '107, 36 ',' Madeira ',' Portugal ',' Over 5 = 'Madeira' and "Country" = 'Portugal' and " Eda
Range 0 to ± os ',' Woman ',' VUELO52488 ') d' = 'Over 50 a ± os' and 'Sex' = 'Male' and
"Flight Details" = 'VUELO52488' and ROWID = 'AAALV
mAAPAAAAn8AAE';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX", "Amount MIN" Amount SUM "= '120, 5 ' and "Amount COUNT" = '1 'to
, "Amount AVG", "City", "Country", "Age Range", "Sex" nd "Max Amount" = '120, 5 "and" Amount MIN =
'12, "Flight Details") values \u200b\u200b('120, 5 ', '1', '120, 5 ', '120 0.5' and 'Amount AVG = '120, 5' and 'City' = ' M
, 5 ', '120, 5', 'Madeira', 'Portugal', 'Over 50 to ± adeira "and" Country "=' Portugal 'and' Range Age" =
os', 'Woman' 'VUELO52561'), 'Over 50 a ± os' and "Sex" = "Woman" and "Flight Of
size" =' VUELO52561 'and ROWID =' AAALVmAAP
AAAAn8AAF ';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX", "Amount MIN" Amount SUM " = '109, 01 'and' Amount COUNT "= '1 '
," Amount AVG "," City "," Country "," Age Range "," Sex "and" Amount MAX' = '109, 01 'and "Amount MIN" = '
, "Flight Details") values \u200b\u200b('109, 01', '1 ', '109, 01', '1 109.01 'and' Amount AVG = '109, 01 'and " City "
09.01 ', '109, 01', 'Madeira', 'Portugal', 'Over 5 =' Madeira 'and" Country " = 'Portugal' and 'Eda
Range 0 to ± os',' Woman ',' VUELO52690 ') d' = 'Over 50 a ± os' and' Sex '=' Male 'and
"Flight Details" = 'VUELO52690' and ROWID = 'AAALV
mAAPAAAAn8AAG';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from" DISCOVERER9I. "EUL5_MV101651" where "
and SUM", "Amount COUNT", "Amount MAX "," Amount MIN "Amount SUM" = '174, 91 'and' Amount COUNT "= '1 '
," Amount AVG "," City "," Country "," Age Range "," Sex "and" Amount MAX = '174, 91 'and' Amount MIN "= '
," Flight Details ") values \u200b\u200b('174, 91', '1 ', '174, 91', '1 174.91 'and' Amount AVG" = ' 174.91 "and" City "
74.91 ', '174, 91', 'Madeira', 'Portugal', 'Over 5 =' Madeira 'and" Country "=' Portugal 'and' Range Eda
0 a ± os', 'Woman', 'VUELO52693') d '=' Over 50 a ± os' and 'Sex' = 'Male' and
"Flight Details" = 'VUELO52693' and ROWID = 'AAALV
mAAPAAAAn8AAH ';

insert into "DISCOVERER9I." EUL5_MV101651 ("Import delete from "DISCOVERER9I." EUL5_MV101651 "where"
and SUM "," Amount COUNT "," Amount MAX "," Amount MIN "Amount SUM" = '131, 5 "and" Amount COUNT "= '1 'to
"Amount AVG", "City", "Country", "Age Range", "Sex" nd "Amount MAX = '131, 5" and "Amount MIN" = '13
, "Flight Details") values \u200b\u200b( '131, 5 ', '1', '131, 5 ', '131 1.5' and 'Amount AVG = '131, 5' and 'City' = 'M
, 5', '131, 5 ' 'Madeira', 'Portugal', 'Over 50 to ± adeira "and" Country "=' Portugal 'and' Range Age" =
os ',' Woman ',' VUELO52951 '),' Over 50 to ± os' and "Sex" = "Woman" and "Flight Of
size" = 'VUELO52951' and ROWID = 'AAALVmAAP
AAAAn8AAI';


9 rows selected.










World List Breast Size By Nationality

Using Access to MSAccess DB from Oracle.


You can access oracle databases are not seamlessly with Oracle Transparent Gateways

.

This feature allows you to configure an ODBC DSN entry as you would any Oracle service. Thus, through a dblink, a user could access a table in a database access (or SQLServer or MySQL, for example) from a query or from PL / SQL.

heterogeneous services architecture is based on the following configuration:

You specify a TNS entry in tnsnames.ora file

resolve a host connection, port and service name specified with the parameter
HS = OK
(Oracle Heterogeneous Services).

On the other hand, the target listener is defined for that service call to a program called "hsodbc" which, through a parameter file init

. Ora enter the DNS associated with specific MSAccess database. In this way, and creating a dblink, anyone could make a select data to cross the Oracle schema and an Access DB. STEPS 1 .- Install the dictionary heterogeneous services.
2 .- Configure the tnsnames.ora


3 .- Configure the listener.


4 .- Check that the listener and the tnsnames.ora work properly. 5 .- Configure ODBC for DB access.

6 .- Create dblink to the DB access. 7 .- Create the init file


. Ora

8 .- Run a query using this dblink.


1 .- Install in the dictionary heterogeneous services
@? / rdbms / admin / caths.sql

NOTE: these views may be installed already in the database.
2 .- Configure the tnsnames.ora bbdd_access =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = tcp)
(HOST =
192,168 .2.4

)


(PORT = 1521)
)
(CONNECT_DATA =
(SERVICE_NAME = odbc_access) ) (HS = OK)
)
3 .- Configure the listener. (Entry in bold is to be added) ...
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0))

)

(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.2.4
)(PORT = 1521))
)
)
)
SID_LIST_LISTENER = (SID_LIST =
(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = D:\oracle\ora92)

(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = D:\oracle\ora92)
(SID_NAME = orcl)
)
(SID_DESC =
(ORACLE_HOME = D:\oracle\ora92)
(SID_NAME = odbc_access)
(PROGRAM = hsodbc)
)
)
4 .- Check that the listener and the tnsnames.ora is working properly.
C: \\ Documents and Settings \\ Administrator> tnsping bbdd_access

TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0 - Production on 08-SEP-2006 18:19: 42

Copyright (c) 1997 Oracle Corporation. All rights reserved.
parßmetros Files used:

D: \\ oracle \\ ora92 \\ network \\ admin
\\ sqlnet.ora

TNSNAMES Adapter used to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)


(HOST = 192.168. 2.4)
(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = odbc_access)) (HS
= OK))
Properly performed (50 ms)


5 .- Configuring ODBC for the DB access.
access the database used in the example has a single table with four rows of example ... create table example (id counter, text value)



need to create an ODBC to access specific access to the database. Since this option is set to Windows Control Panel, Administrative Tools, ODBC Manager and the System DSN tab.

from there establishing odbc_access driver connected to the database you use: "test_hs.mdb" with this example table.



NOTE: This access is password bbdd "tesths"
6 .- Create dblink to the DB access. SQL> CREATE DATABASE LINK bbdd_access
2 CONNECT TO ADMIN TESTHS
3 IDENTIFIED BY USING 'bbdd_access';
Link to the database created.
7 .- Create the init file
. Ora in the directory ORACLE_HOME / hs / admin /


- FILE initODBC_ACCESS.ora
#




# HS init parameters


# HS_FDS_CONNECT_INFO = odbc_access
HS_FDS_TRACE_LEVEL = 0

HS_FDS_TRACE_FILE_NAME = odbc_access.trc

HS_AUTOREGISTER = TRUE



8 .- Launch the query via the dblink
SQL> column "value" format a40
SQL> set pages 1000
SQL> set Lines 120

SQL > select * from @ bbdd_access example,

id
value
---------- ---------------------- -------- ----------
1 data1
2 data2
3 data3

4 dato4


Book About Weight Watcher

SQL Query Optimization in Oracle Oracle

The following query takes 11 hours to run.
SELECT DISTINCT A.
NODO_ID, B. NODO_B_ID NODO_EQ1 BITOWN03.BS_R_NODOS_BIT_03 FROM A BITOWN03.RE_R_CONEX_EXTERNAS_BIT_03 B, C
BITOWN03.TMP_NODOS_OK_EST_BIT_03
NODO_ID = B WHERE A. AND B. NODO_A_ID NODO_B_ID = C. NODO_ID;
the following implementation plan SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls PLAN_TABLE_OUTPUT --------------------------------------- ---------------------------------------------- ------------------------------------------------- ---------------------------------- Predicate Information (identified by Operation id): ---- -----------------------------------------------
7 - access ("B". "NODO_B_ID" = "C". "NODO_ID" AND "A". "NODO_ID" = "B". "NODO_A_ID)
Note: CPU Costing is off




** ************************************************** ****************************
SOLUTION to the case.

************************************************ ******************************** Another
Cartesian product. In this case the Cartesian knows what he does. Cross almost 6,000 million rows (a total of 61 gigabytes of data) and at minimal cost. What a paradox.
A detail to understand this decision: there are no restrictions on Primary Key or Foreign Key
or unique indexes, constraints or Not Null.

Because of this, Oracle is practical to combine all the results of a table (4.5 million) over the 1400 rows in another table, a
"everyone with everyone"
.



Not bad. However, no information to Oracle, much to analyze the tables, it will not be able to get

priori. We are interested only unique values \u200b\u200bin the relationship table, which exist in their related tables, but as I say, there is nothing to provide that information to Oracle.

change some details of the consultation and leave it like that:








SELECT DISTINCT A.

NODO_ID, B. NODO_B_ID NODO_EQ1
FROM BITOWN03.BS_R_NODOS_BIT_03 A,
(select distinct nodo_a_id, nodo_b_id from BITOWN03 . RE_R_CONEX_EXTERNAS_BIT_03) B, C
BITOWN03.TMP_NODOS_OK_EST_BIT_03
NODO_ID = B WHERE A. AND B. NODO_A_ID
NODO_B_ID = C. NODO_ID;


Report of two things: that I have interest in obtaining the separate codes in the relationship table, and also exist in the other two tables.

The implementation plan to run completely changed as I have said otherwise

. Now Oracle does this other implementation plan.

SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls
PLAN_TABLE_OUTPUT -------------------------- --------------------------------------------------
----------------- ------------------------------- --------------------------------------------------
------------ 81M
13626 cost units. Regarding the previous cost of only 23. But now appears the Cartesian and it seems that the implementation is more faithful to what we want. I have just released
implementation:
one minute and twenty seconds. Well
.

What's The Strongest Underwear

Tips: Change character set parameter in the database

1. Check NLS_CHARACTERSET


Connect to SYS or SYSTEM user




SELECT * FROM V $ NLS_PARAMETERS


WHERE PARAMETER = 'NLS_CHARACTERSET';
Parameter Value

NLS_CHARACTERSET AL32UTF8





If you want to change NLS_CHARACTERSET from AL32UTF8 to TH8TISASCII



2. Connect to user SYS



3. Update value





UPDATE PROPS$


SET VALUE$ = 'TH8TISASCII'


WHERE NAME = 'NLS_CHARACTERSET';


COMMIT;

4. Restart database

STARTUP;

5. Check NLS_CHARACTERSET
Connect to user SYS or SYSTEM
SELECT * FROM

V$NLS_PARAMETERS
WHERE PARAMETER = 'NLS_CHARACTERSET';
Parameter Value
NLS_CHARACTERSET TH8TISASCII

Property Tax In Houston Area

SQL Query Optimization in Oracle

The following query
was canceled after 15 hours and 37 minutes
execution.
SQL> select count (*) from (SELECT BITOWN03.BS_C_CLIENTES_BIT_03.DNICIF_DE, BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.CONTRATO_ID 2, 3 HSCONTRATOS_ESTADOS.ESTADO_DE
, BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.FEC_ESTADO_DT 4, 5 BITOWN03.BS_C_CLIENTES_BIT_03.ABONADO_ID
6 FROM BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03 7, 8 BITOWN03.LK_C_ESTADOS_BIT_03 HSCONTRATOS_ESTADOS,
BITOWN03.BS_C_CLIENTES_BIT_03 9, 10 BITOWN03.BS_C_CONTRATOS_BIT_03 CONTRACT = 11 WHERE BITOWN03.BS_C_CLIENTES_BIT_03.ABONADO_ID CONTRATOS.ABONADO_ID
BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.CONTRATO_ID = 12 AND 13 AND CONTRATOS.CONTRATO_ID
BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.ESTADO_ID HSCONTRATOS_ESTADOS.ESTADO_ID = 14 BETWEEN 15 AND BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.FEC_ESTADO_DT to_date ('01-06-2005 00:00:00 ',' DD-MM-YYYY HH24: MI: SS ') AND 16
to_date ('30-23 06-2005: 59:59 ',' DD-MM-YYYY HH24: MI: SS ') AND 17 BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03.ESTADO_ID =' BA '); BITOWN03.HS_C_ESTADOS_CONTRATO_BIT_03,
* ERROR at line 7: ORA-00028: your session has Been Killed

Elapsed: 15:37:01.66

the following implementation plan

SQL> @ C: \\ ORACLE \\ ORA92 \\ RDBMS \\ ADMIN \\ UTLXPLS
PLAN_TABLE_OUTPUT -------------------------------------- --------------------------------------------------
-------------------------------- ---------------- -------------------------------------------------- -------------------------------------------------- -

Predicate Information (identified by Operation id): --------------------------------------
------------- 5 - access ("HSCONTRATOS_ESTADOS. ESTADO_ID" = 'BA') 6 - access ("HS_C_ESTADOS_CONTRATO_BIT_03. FEC_ESTADO_DT> = TO_DATE ('2005- 06-01 00:00:00 ',' yyyy-mm-dd HH24: mi: ss') AND "HS_C_ESTADOS_CONTRATO_BIT_03. ESTADO_ID" = 'BA' AND
"HS_C_ESTADOS_CONTRATO_BIT_03. FEC_ESTADO_DT"
filter ("HS_C_ESTADOS_CONTRATO_BIT_03 . ESTADO_ID "=" HSCONTRATOS_ESTADOS. ESTADO_ID "AND " HS_C_ESTADOS_CONTRATO_BIT_03. ESTADO_ID "= 'BA') 9 - filter (" BS_C_CLIENTES_BIT_03. ABONADO_ID "=" contracts "." ABONADO_ID)
10 - access ("HS_C_ESTADOS_CONTRATO_BIT_03." CONTRATO_ID "=" Contracts. "CONTRATO_ID) Note: cpu costing is off **************** ************************************************** SOLUTION **************
the case. ************************************************ ********************************



The tables contain statistics faithful. The Cartesian product not deceived: cross 58 GB to meet our request. Anyway, something is wrong. That plan is not optimal.

statistics generated by the next call to DBMS_STATS

.


SQL> begin 2 DBMS_STATS.GATHER_TABLE_STATS
(OWNNAME => user,
3 TABNAME => table,
4 ESTIMATE_PERCENT => dbms_stats.auto_sample_size,
5 METHOD_OPT => 'FOR ALL INDEXED COLUMNS SIZE 1', 6 DEGREE
=> 4);
7 end;
8 /

PL / SQL procedure successfully completed.



must not only analyze the tables, but also the indices. Some of them are analyzed using the procedure
DBMS_STATS.GATHER_INDEX_STATS
, but one of the tables is partitioned. The best and simplest is to include the parameter
CASCADE => TRUE
in the call to DBMS_STATS .
is true that the cost of increased analysis of these tables. In addition, the CASCADE parameter affects not only rates but also materialized views, partitions, etc.. (Ie, all its dependencies).

With tables analyzed in this way, the new implementation plan is this:









SQL> @c:\oracle\ora92\rdbms\admin\utlxpls

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------
BY INDEX ROWID 00:00:00 ',
' yyyy-mm-dd HH24: mi: ss ') AND "HS_C_ESTADOS_CONTRATO_BIT_03." ESTADO_ID "=' BA 'AND
" HS_C_ESTADOS_CONTRATO_BIT_03. "FEC_ESTADO_DT"
HH24: mi: ss') )
filter ("HS_C_ESTADOS_CONTRATO_BIT_03." ESTADO_ID "= 'BA')
6 - access (" HSCONTRATOS_ESTADOS. "ESTADO_ID" = 'BA')
9 - access ("BS_C_CLIENTES_BIT_03." ABONADO_ID "=" Contracts. " "ABONADO_ID)

Note: cpu costing is off 30 rows selected
<=TO_DATE('2005-06-30 23:59:59', 'yyyy-mm-dd hh24:mi:ss'))
.





The execution now takes only:
3 seconds.

The cost of testing increases of 26 minutes 32 minutes. The gain justifies the cost.

Okay. :-)


# posted by Javier Morales @ 6:13 PM 0 comments








Monday, October 17, 2005



NOT IN vs. NOT EXISTS.



to Fernando, which awaits. :-P The following query was canceled after 5 hours and 11 minutes
run.



SELECT count (CLI.COD_ABONADO)
BITOWN02.TM_C_CLIENTES_SAC_02 FROM CLI,
BITOWN02.TE_ERRORES_BIT_02 WHERE YOU
TE.FILA_ID CLI.ROWID = (+)
AND 'TM_C_CLIENTES_SAC_02' = TE.TABLA_DE (+) TE.ERROR_ID IS NULL AND CLI.COD_ABONADO AND NOT IN (SELECT
FROM CU.ABONADO_id BITOWN03.BS_C_CONTRATOS_BIT_03 CONT, CU BITOWN03.BS_C_CUENTAS_BIT_03 WHERE CU.CUENTA_ID = CONT.CUENTA_ID
)




the following implementation plan


SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls


PLAN_TABLE_OUTPUT ------------------------------------------------

----------- ------------------------------------- -------------------------------------------------- --------------------------------------------
HASH JOIN OUTER ACCESS BY INDEX ROWID
: B1)))
3 - filter ("TE_M_ERRORES_BIT_01. ERROR_ID" IS NULL)
4 - access ("SYS_ALIAS_1." ROWID = "TE_M_ERRORES_BIT_01. FILA_ID "(+))
10 - filter (LNNVL ( "CU." ABONADO_ID "
: B1))
11 - access (" CU "." CUENTA_ID "=" account "." CUENTA_ID)

Note: CPU Costing is off 30 rows selected

.

<=TO_DATE('2005-06-30 23:59:59', 'yyyy-mm-dd

********************************************** **********************************

SOLUTION to the case.

************************************************ ********************************


In this case, consultation with IN has an acceptable cost. However, after five hours of execution, one suspects that things are not going well. The implementation strategy is to make two FILTER: one for the Client OuterJoin without errors and the second to combine (in a very heavy NestedLoops) with contract accounts.
As the subquery is becoming even heavier than the main can be replaced by
IN

EXISTS clause is
a good strategy.

Yes, I have also been careful not null codes to answer the inquiry, as NOT IN and NOT EXISTS

Explain plan for SELECT count (CLI.COD_ABONADO)

BITOWN02.TM_C_CLIENTES_SAC_02 FROM CLI, BITOWN02.TE_ERRORES_BIT_02 WHERE YOU CLI.ROWID = TE.FILA_ID (+)

AND 'TM_C_CLIENTES_SAC_02' = TE.TABLA_DE (+)

TE.ERROR_ID IS NULL AND
AND NOT EXISTS (SELECT null BITOWN03.BS_C_CONTRATOS_BIT_03 CONT FROM, WHERE BITOWN03.BS_C_CUENTAS_BIT_03 CU CLI.COD_ABONADO = CU.ABONADO_ID AND CU.CUENTA_ID = CONT.CUENTA_ID)


The resulting execution plan appears to be similar to the above, including the cost seems worse.



SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls

PLAN_TABLE_OUTPUT
------------------------- --------------------------------------------------

------- ----------------------------------------- -------------------------------------------------- --------------------------------------------------
---------
11
11 - access ("CU". "CUENTA_ID" = "CONT." CUENTA_ID)
Note: cpu costing is off



I launch the performance:
28 seconds.

Très bien. :-)





# posted by Javier Morales @ 6:12 PM 0 comments










Thursday, October 13, 2005



Say it otherwise.


<>
To Manel Moreno, who has given me no kiss for that.
: P
<>


The following query takes 11 hours to run.


SELECT DISTINCT A.

NODO_ID, B. NODO_B_ID NODO_EQ1
FROM BITOWN03.BS_R_NODOS_BIT_03 A,
BITOWN03.RE_R_CONEX_EXTERNAS_BIT_03 B, C BITOWN03.TMP_NODOS_OK_EST_BIT_03 NODO_ID = B WHERE A. AND B. NODO_A_ID
NODO_B_ID = C. NODO_ID;



the following implementation plan SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls PLAN_TABLE_OUTPUT
------------- --------------------------------------------------
---------------------- -------------------------- -------------------------------------------------- ------- solution to the case. ************************************************ ********************************


Another Cartesian product. In this case the Cartesian knows what he does. Cross almost 6,000 million rows (a total of 61 gigabytes of data) and at minimal cost. What a paradox.

A detail to understand this decision: there are no restrictions on Primary Key or Foreign Key
or unique indexes, constraints or Not Null. Because of this, Oracle is practical to combine all results in a table (4.5 million) over the 1400 rows in another table, a
"everyone with everyone" .


Not bad. However, no information to Oracle, much to analyze the tables, it will not be able to obtain a priori

. We are interested only unique values \u200b\u200bin the relationship table, which exist in their related tables, but as I say, there is nothing to provide that information to Oracle.

change some details of the consultation and leave it like that:






SELECT DISTINCT A.

NODO_ID, B. NODO_B_ID NODO_EQ1
FROM BITOWN03.BS_R_NODOS_BIT_03 A,
(select distinct nodo_a_id, nodo_b_id from BITOWN03.RE_R_CONEX_EXTERNAS_BIT_03) B, C
BITOWN03.TMP_NODOS_OK_EST_BIT_03 NODO_ID = B WHERE A. AND B. NODO_A_ID
NODO_B_ID = C. NODO_ID;





report of two things : that I have interest in obtaining the separate codes in the relationship table, and also exist in the other two tables.

The implementation plan to run completely changed as I have said otherwise

. Now Oracle does this other implementation plan.




SQL> @ c: \\ oracle \\ ora92 \\ rdbms \\ admin \\ utlxpls

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
VIEW

6 - access ("B". "NODO_B_ID" = "C". "NODO_ID)
7 - access (" A "." NODO_ID "=" B "." NODO_A_ID)







The cost now seems completely shot. 13626

cost units. Regarding the previous cost of only 23. But now appears the Cartesian and it seems that the implementation is more faithful to what we want. I have just released
implementation:
one minute and twenty seconds. Well
.
# posted by Javier Morales @ 6:11 PM 0 comments

Poor Cardinality

For Cristina Alvarez, who trusted me from day one and hid it with all his soul.

:)
The following query was canceled after one hour and twenty minutes of execution.


SELECT N2.ENTIDAD_ID, CLI.rowid Row_A, cli .*,
MAX (REL.ABONADO_PADRE_ID) OVER (PARTITION BY ABONADO_HIJO_ID) REL_ABONADO_PADRE_ID BITOWN03.BS_V_MGEC_NODO_BIT_03 FROM N1, N2 BITOWN03.BS_V_MGEC_NODO_BIT_03 ,
BITOWN03. BS_V_MGEC_REL_NODOS_BIT_03 RN,
BITOWN02.TM_C_CLIENTES_SAC_02 CLI, REL BITOWN03.RE_C_RELACIONES_ABONADO_BIT_03

N1.ENTIDAD_ID = CLI.COD_DNICIF
WHERE AND AND N1.NODO_ID = RN.NODO_ID
RN.FECHA_FIN_DT RN.TIPO_RELACION_ID = 2 AND IS NULL AND RN.NODO_PADRE_ID
AND CLI = N2.NODO_ID
. COD_ABONADO = REL.ABONADO_HIJO_ID (+);



the following implementation plan



PLAN_TABLE_OUTPUT
-------------------- --------------------------------------------------

----------------------------- ------------------- --------------------------------------------------
------------------------------ Rows 1
filter ("CLI". "COD_ABONADO" = "REL." ABONADO_HIJO_ID "(+))
11 - filter ("N1". "ENTIDAD_ID" = "CLI". "COD_DNICIF)
12 - access (" N1 "." NODO_ID "=" RN "." NODO_ID)
14 - access ("RN". "NODO_PADRE_ID" = "N2". "NODO_ID)





********* ************************************************** *********************

solution to the case.

************************************************ ********************************

Omitting the detail that the clause distinct enough. The plans maintain that resulting from similar performances.



seems quite acceptable plan. However, a Cartesian product attention ... "Only get a row? In this case, the Cartesian will not hurt. We will see the total of rows in the table if the table has generated statistics (column num_rows
of
user_t
can give us a clue) and if the filter operation 7 really solves a single row.






SQL> select count (*) from bitown03.BS_V_MGEC_REL_NODOS_BIT_03;
COUNT (*) ----------



118,907

SQL> select table_name, NUM_ROWS from dba_tables 2 WHERE table_name = 'BS_V_MGEC_REL_NODOS_BIT_03';


NUM_ROWS TABLE_NAME ------------------------------ ----------



BS_V_MGEC_REL_NODOS_BIT_03 118,907



SQL> select count (*) from bitown03.BS_V_MGEC_REL_NODOS_BIT_03

TIPO_RELACION_ID 2 where = 2 AND FECHA_FIN_DT IS NULL; -> FILTER OPERATING 7




COUNT (*) ----------









12844 Apparently not ... We're seeing a Cartesian product of 1.5 million rows (FULL TABLE SCAN operation 9) on 12,844 items. Oracle is bad estimating the cardinality of the rows. Cree for filter 7 only get one row and therefore does not trigger the Cartesian product cost. Fatty

error.

must correctly analyze the tables involved, indicating that they also analyze the values \u200b\u200bof the columns involved. The commands to perform this analysis are:



SQL> exec dbms_stats.gather_table_stats (OWNNAME => 'user', TABNAME => 'BS_V_MGEC_REL_NODOS_BIT_03' METHOD_OPT => 'for all columns');

PL / SQL procedure successfully completed.

Elapsed: 00:00:07.71
SQL> exec dbms_stats.gather_table_stats (OWNNAME => 'user', TABNAME => 'BS_V_MGEC_NODO_BIT_03' METHOD_OPT => 'for all columns');

PL / SQL procedure successfully completed.
Elapsed: 00:00:14.57



PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------

7 - filter ("RN". "TIPO_RELACION_ID" = 2 AND "RN". "FECHA_FIN_DT" IS NULL) 11 - access ("CLI". "COD_ABONADO" = "REL." "(+))

ABONADO_HIJO_ID filter ("CLI". "COD_ABONADO" = "REL." "(+))

ABONADO_HIJO_ID Note: cpu costing is off
Indeed, the plan's cost is higher, but REAL.

has taken only 23 seconds!