ORACLETuning
Lowy Shin edited this page Oct 14, 2020
·
14 revisions
- Find SQL Usage
- Check index and table full scan, etc.
- add or correct index
- suggest PK(clustered index)
- rewrite SQL by data size and statistics
- Locking SQL text
SELECT
s.machine,
a.sql_text
FROM v$session s,
v$sqlarea a,
v$process p
WHERE s.PREV_HASH_VALUE = a.hash_value
AND s.PREV_SQL_ADDR = a.address
AND s.paddr = p.addr
AND sid in (
select SID from v$lock
where type in ('TX', 'XR')
)
order by s.machine
;
- Count executed SQL by machine
SELECT
s.machine,
count(1) as Cnt
FROM v$session s,
v$sqlarea a,
v$process p
WHERE s.PREV_HASH_VALUE = a.hash_value
AND s.PREV_SQL_ADDR = a.address
AND s.paddr = p.addr
group by s.machine
order by count(1) desc, s.machine
;
- Count executed SQL by SQL_TEXT
SELECT
count(1) as Cnt,
a.sql_text
FROM v$session s,
v$sqlarea a,
v$process p
WHERE s.PREV_HASH_VALUE = a.hash_value
AND s.PREV_SQL_ADDR = a.address
AND s.paddr = p.addr
group by a.sql_text
order by count(1) desc, sql_text
;
- Last SQL execute time and source on memory.
select last_active_time,parsing_schema_name,sql_text from v$sqlarea
order by last_active_time desc;
- Useful column by SQL on memory
SELECT
count(1) as Cnt,
s.status, s.machine, s.osuser, s.module, s.username, p.program, a.sql_text
FROM v$session s,
v$sqlarea a,
v$process p
WHERE s.PREV_HASH_VALUE = a.hash_value
AND s.PREV_SQL_ADDR = a.address
AND s.paddr = p.addr
group by
s.status, s.machine, s.osuser, s.module, s.username, p.program, a.sql_text
order by count(1) desc, machine, sql_text
;
- all table size
SELECT
a.owner
, a.table_name
,a.num_rows
, b.MB
FROM all_tables a
, (Select Segment_Name,Sum(bytes)/1024/1024 MB From dba_segments Group By Segment_Name) b
WHERE a.table_name = b.Segment_Name
ORDER BY b.MB desc, a.num_rows desc;
if you can not see row number, execute below system procedure gather_table_stat
- FInd table owner and size(rownum) check
select OWNER, TABLE_NAME, TABLESPACE_NAME, NUM_ROWS, TABLESPACE_NAME
from all_tables
where TABLE_NAME in ('<Table name>')
;
- Execute if NUM_ROWS is null of above SQL
exec dbms_stats.gather_table_stats('<Owner>', '<Table Name>');
- Find column name from all tables
select *
from all_tab_columns
where column_name like '<Column Name>'
;
- Get index info
select * from all_indexes
where TABLE_NAME in ('<Table Name>')
;
select * from all_ind_columns
where INDEX_NAME in (
select INDEX_NAME from all_indexes
where TABLE_NAME in ('<Table Name>')
)
order by TABLE_NAME, INDEX_NAME, COLUMN_POSITION
;
- Put plan table
explain plan for
select AAA, count(1) from TABLENAME group by AAA;
select *
from PLAN_TABLE
where to_char(TIMESTAMP, 'YYYYMMDDHH24MISS') in (select MAX(to_char(TIMESTAMP, 'YYYYMMDDHH24MISS')) from PLAN_TABLE)
order by PARENT_ID, ID
;
- DWH tuning, Query statistics (jp)
- Oracle 11g movement Notes
- Lock mode explain and solution
- Lock mode description
- KB wiki is multi-lingual writing. If you want translate to your language, use google translate!
- Go to giip service Page : http://giipweb.littleworld.net
- Documentation : https://github.com/LowyShin/giip/wiki
- Sample automation scripts : https://github.com/LowyShin/giip/tree/gh-pages/giipscripts
See more : https://github.com/LowyShin/giip/wiki
- Token exchanges : https://tokenjar.io/GIIP
- Token exchanges manual : https://www.slideshare.net/LowyShin/giipentokenjario-giip-token-trade-manual-20190416-141149519
- GIIP Token Etherscan : https://etherscan.io/token/0x33be026eff080859eb9dfff6029232b094732c52
If you want get GIIP, contact us any time!
- LowyWorkEnv : https://github.com/LowyShin/Lowyworkenv/wiki
- CLoud RDBMS比較
- MachineLearning
- SQL Server
- ORACLE
- MySQL
- mariadh
- Redis with MySQL
- Mongodb
- Apache-Drill
- A5MK2-MultiDBMSTool
- BI
- Referrals
- Juliaの自動微分パッケージ Zygote の紹介
- color code table
- Canva - free Online Design tool
- vscode
- git(github)
- GoogleSheet
- UiPath(RPA)
- WinAutomation(official)
- Excel
- VNC
- VPN
- Note Tool
- Blog
- google news alert
- Online PDF to JPG
- LoadTest " putty
- Shell/bash
- crontab
- PowerShell
- Windows(DOS) batch
- Wscript/wsf
- AWS
- Azure
- File Sync(rsync, scp...)
- KnownPort(wikipedia)
- CentOS(Linux)
- Windows10
- Android