Oracle's SQL statement optimization

Source: Internet
Author: User

Oracle's SQL statement optimization
Optimization of SQL statements

1. The Oracle optimizer cannot use indexes when using is NULL or is not NULL in the WHERE clause.



2. For connected columns, even if the most one is a static value, the optimizer does not use indexes such as: SELECT * from Employss where first_name| | "| | Last_name= ' Beill Cliton ' to be written: SELECT * from Employss where first_name= ' Beill ' and last_name= ' Beill Cliton ' then Oracle uses the base Index in Last_Name



3. Wildcard characters (%) Like statements such as: SELECT * from the employee where last_name '%cliton% '; % at the beginning of the word the Oracle system cannot use the last_name index; select * FROM employee where last_name like ' cliton% '



4:order by any non-indexed item or expression in the order BY statement will reduce the query efficiency;

5:not $amp;<amp; $gt; is equivalent to not p= "" When Oracle Encounters "not, he stops using the index instead of performing a full-table scan. <=" "not produces the same effect as using functions on an indexed column. =" " ① and ② query results are the same, but ② allows Oracle to use indexes on salary columns, high efficiency = "<3000=" "salary=" "or=" ">3000=" "from=" "*=" "select= amp;<amp; $gt; 3000;= "" ①= ">

6:exist instead of in-not exist instead of in-select * from A where-ID in (select-ID from B) the above query uses the in statement, in () executes only once, it detects all the ID fields in table B and caches them. After that, check that the ID of table A is equal to the ID in table B, and if it is equal, add the records of table A to the result set until all records of table A are traversed. exist performs more efficiently than in




7:



Order of 8.where conditions




9:union All and UNION

Oracle's SQL statement optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.