Replacing like with instr in Oracle databases

Source: Internet
Author: User

The following articles mainly introduce how to replace like with instr in Oracle databases. Suppose there is 11 million data in the table. In many cases, we perform String Matching on it, in the practical application of SQL statements, we generally use like to achieve our search goal.

However, the actual test shows that the like efficiency is quite different from the instr function. The following are some test results:

 
 
  1. SQL> set timing on
  2. SQL> select count (*) from t where instr (title, 'manual')> 0;
  3. COUNT (*)
  4. ----
  5. 65881
  6. Elapsed: 00:00:11. 04
  7. SQL> select count (*) from t where title like '% manual % ';
  8. COUNT (*)
  9. ----
  10. 65881
  11. Elapsed: 00:00:31. 47
  12. SQL> select count (*) from t where instr (title, 'manual') = 0;
  13. COUNT (*)
  14. ----
  15. 11554580
  16. Elapsed: 00:00:11. 31
  17. SQL> select count (*) from t where title not like '% manual % ';
  18. COUNT (*)
  19. ----
  20. 11554580

Note:

Instr (title, 'manual')> 0 is equivalent to like

Instr (title, 'manual') = 0 is equivalent to not like


The above content is the description of replacing like with instr for the Oracle database, hoping to provide you with some help in this regard.

Edit recommendations]

Related Article

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.