Home > Ask the Oracle Database / Applications Experts > Oracle performance tuning Questions & Answers > Improve performance of SQL query
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Improve performance of SQL query

Phillip Bracken EXPERT RESPONSE FROM: Phillip Bracken

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 29 May 2007
How can I improve the performance for this SQL? The value of a.a, b.from, b.to is a number in varchar type.
update a
set a.a = 'exist'
where a.a in( select a.a  from a, b where a.a >=b.from and a.a <= to)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Oracle performance tuning
Can I use TKPROF in Oracle 10g?
How to improve performance of column update
Select on Oracle table takes hours
Import of database dump takes 13 hours
Slow query performance for customer with large data volume
ORA-03297 when trying to resize tablespace
SMON process consuming 100% CPU
Total Oracle CPU time
See tablespace utilization/database size without DBA privileges
Simple SQL query takes longer than usual

Oracle database performance problems and tuning
Oracle tutorial library: SearchOracle.com's learning guides
What managers should consider when starting a database scaling project
Oracle releases new database, says 11g upgrade will cut costs
Oracle raises prices on database management packs
Oracle New Year's resolutions, part 1: Advice for navigating 2009
Solving common Oracle errors guide
Oracle 11g data compression
Varchar or number for better performance?
Do statistics on SYS-owned objects hurt performance in 10g?
Inside the Oracle 11g SQL Performance Advisor, part 1

Oracle and SQL
Oracle tutorial library: SearchOracle.com's learning guides
Can I specify Oracle column order in my database table?
Review: Oracle's 11g R2 database has some good and bad
SELECT statement syntax and examples
Oracle PL/SQL tutorial
PL/SQL datatypes in Oracle
Stored procedures in PL/SQL
PL/SQL functions and triggers in Oracle
Do I need a license for SQL Developer Data Modeler in Oracle?
Using the SQL GROUP BY clause for counting combinations
Oracle and SQL Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
autonomous transaction  (SearchOracle.com)
CFML  (SearchOracle.com)
dynamic SQL  (SearchOracle.com)
foreign key  (SearchOracle.com)
Java Database Connectivity  (SearchOracle.com)
Open Database Connectivity  (SearchOracle.com)
Oracle  (SearchOracle.com)
stored procedure  (SearchOracle.com)
The Open Group  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


You don't mention what indexes you have on these tables nor what access path Oracle is currently taking. First of all, do an explain plan on this SQL, if you haven't already, to see what access plan is using to access the table. This information will tell what if Oracle is using any indexes or doing full table scans.

The first thing I would try is instead of using an IN, I would use an EXISTS, as such:

Update a
set a.a = 'exist'
where EXISTS ( select 1  from a, b where a.a >=b.from and a.a <= to)

Using an IN will probably cause Oracle to bypass using an index, if one exists, and cause the Optimizer to use a table scan to access table a.

Another option, if these tables are large, I would consider indexing column 'from' on table b if it is not indexed already. You might also want to consider indexing column 'a' on table a, if that table is not updated very frequently. The index on column a in this example, will help on the subquery, but it will hurt you when doing the update since the index on column a will be updated causing extra I/O. As a result, the index may actually hurt performance but it will depend on the number of rows that are updated, and the current size of the table.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts