ba6.us - Dave's Database Related Stuff

  • home
  • blog
  • books
  • projects
  • about
  • !
Home

Search

Tags

apex development funnies monitoring oracle performance perl rman sql sqlplus unix windows
more tags

Navigation

  • Feed aggregator

Recent blog posts

  • Oracle IN Condition and Multi Column Subqueries
  • SQL For Dinosaurs
  • Quickie script to run dbv on your database...
  • Permissions for Autotrace
  • Accuracy of PROFILER.SQL from Metalink Doc: 243755.1
  • Recording Oracle System Stats for historical analysis...
  • Shell Script to Run a SQLPLUS against all databases running on a server...
  • Viewing command line args with Solaris ps utility...
  • Orion IO Test Tool
  • Documented Hints available in 11.2...
more

Books

  • What Are Books?
  • Execution Plans
  • Application Express Tips
  • Copying Databases
  • Distributed Transactions
  • Instance Differences
  • Instance Info
  • Materialized Views
  • Operating System Monitoring
  • Perl
  • Perl and Oracle
  • PL/SQL
  • Real Time Monitoring of Oracle
  • SQL Profiles
  • SQLDeveloper for Non Dummies
  • Statistics
  • Tablespace Info
  • Unix Shell Scripting
  • User Security

RSS Feed - Blog Posts

Syndicate content

User login

  • Create new account
  • Request new password

Blogs

Oracle IN Condition and Multi Column Subqueries

dmann — Fri, 02/19/2010 - 15:02

I keep coming across a construct in some legacy SQL that has been causing all kinds of performance issues for us. I guess you could call it using the IN condition with multi-column subqueries. I located the syntax for the IN condition here but it doesn't really get into much detail about using this construct.

Here is an example of the subquery (it returns the lowest salary and department_id for each department):
Read more »

  • oracle
  • sql
  • dmann's blog
  • Add new comment

SQL For Dinosaurs

dmann — Thu, 02/18/2010 - 16:40

  • funnies
  • dmann's blog
  • Add new comment

Quickie script to run dbv on your database...

dmann — Fri, 01/22/2010 - 11:49

This script will generate dbv commands into a shell script and then execute the shell script.

run-dbv.sql:

set head off
set lines 200
set feedback off
set define off
spool dbv.sh

select 'dbv file='||name||' blocksize = '||block_size||
       ' LOGFILE=FILE-'||FILE#||'.LOG' from v$datafile;
spool off

host chmod 755 dbv.sh
spool dbv_results.log
host ./dbv.sh
spool off

Output will be created as separate log files. You can run it and review results like this:

$ sqlplus "/ as sysdba" @run-dbv.sql
 Read more »
  • dbv
  • dbverify
  • oracle
  • shell scripting
  • unix
  • dmann's blog
  • Add new comment

Permissions for Autotrace

dmann — Tue, 01/12/2010 - 15:06

If you want to run AutoTrace using Toad using a non sys or system user, give your user the following select privileges:

grant select on v_$session to &traceuser.;
grant select on v_$sesstat to &traceuser.;
grant select on v_$statname to &traceuser.;

Alternately you can run $ORACLE_HOME/sqlplus/admin/plustrce.sql and then grant the PLUSTRACE role to the user that needs to run AutoTrace.

-Dave

  • autotrace
  • permissions
  • toad
  • dmann's blog
  • Add new comment

Accuracy of PROFILER.SQL from Metalink Doc: 243755.1

dmann — Mon, 01/04/2010 - 15:25

I came across a situation where the profiler.sql supplied with Metalink Doc: 243755.1 was giving some incomplete results. Because some of my PL/SQL code was executing very quickly it was rounding down to 0.00 and not even showing up on the 'Top 10' section.

Throughout profiler.sql there are timing numbers (unit = sends) that are rounded to 2 places. Looking in the comments for profiler.sql I noticed the last update was early 2007. Maybe Moore's law and CPU power has caught up with profiler.sql but I would recommend increasing the granularity of the script by doing the following: Read more »

  • pl/sql
  • profiler
  • dmann's blog
  • Add new comment

Recording Oracle System Stats for historical analysis...

dmann — Thu, 12/31/2009 - 14:27

If you are experimenting with gathering system statistics it might be helpful to archive your current settings and any intermediate settings you come up with along the way.

There is a way to save stats to a table using DBMS_STATS.CREATE_STAT_TABLE and gathering with DBMS_STATS.GATHER into that table, but the format is cryptic and it is nice to have the descriptive parameter names tagging along with the data. (In a future post I will cover format of the CREATE_STAT_TABLE format).

The current system stats info is held in the sys.aux_stats$ table. Since the format is a little wacky, I came up with the following table to hold stats and the following insert statement to populate it after every gathering of system stats.

Now you can easily query the values of old stats in the SYSTEM_STATS_HISTORY table: Read more »

  • oracle
  • system stats
  • dmann's blog
  • Add new comment

Shell Script to Run a SQLPLUS against all databases running on a server...

dmann — Tue, 12/29/2009 - 14:33

#!/usr/bin/bash
#---------------------------------------------------------------------------
# Written by  : David Mann @ http://ba6.us
# Script Name : alldatafiles.sh
# Description : Provides list of all datafiles for each running database on 
#               on a machine
#---------------------------------------------------------------------------

ORATAB=/etc/oratab
echo "INSTANCE_NAME, FILE_NAME"

# Step through running instances
ps -ef | grep ora_smon_ | grep -v grep | cut -b61-70 | while read LINE
do
    # Assign the ORACLE_SID
    ORACLE_SID=$LINE
 Read more »
  • shell script
  • sqlplus
  • dmann's blog
  • Add new comment

Viewing command line args with Solaris ps utility...

dmann — Wed, 12/09/2009 - 16:45

If you ever used the Solaris ps -ef command to view programs that are running you may not always see the arguments the original program was started with. This command usually shows about 80 characters.

Try the following commands, they usually give you more information about the command that started the process running. Depending on the patch level of your OS you may see 200 characters or more.

/usr/ucb/ps
/usr/ucb/ps -auxwww

-Dave

  • command line
  • ps
  • solaris
  • dmann's blog
  • Add new comment

Orion IO Test Tool

dmann — Tue, 12/01/2009 - 22:54

I ran across Orion in a Kevin Closson blog post. From the OTN site:

"ORION (Oracle I/O Calibration Tool) is a standalone tool for calibrating the I/O performance for storage systems that are intended to be used for Oracle databases. The calibration results are useful for understanding the performance capabilities of a storage system, either to uncover issues that would impact the performance of an Oracle database or to size a new database installation. Since ORION is a standalone tool, the user is not required to create and run an Oracle database. " Read more »

  • disk
  • oracle
  • performance
  • dmann's blog
  • Add new comment

Documented Hints available in 11.2...

dmann — Wed, 11/25/2009 - 11:53

As I get deeper into tuning with Statistics and the CBO I have been paying a lot more attention to hints.

In the past I always tried to avoid hints. After working with the CBO and staistics in recent versions I believe they are necessary at times to give guidance to the CBO.

The Oracle Database SQL Language Reference has a comprehensive list of hints included in the documentation of SQL Comments. The list for 11g is available here: link. Read more »

  • Hint
  • sql
  • dmann's blog
  • Add new comment
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • next ›
  • last »
Syndicate content


Cornify
  • home
  • blog
  • books
  • projects
  • about
  • !

Content Copyright 2006-2010. Links are copyright of respective owners.