Get the App
SLTechnology News&Howtos  ›  Database  › 

ORACLE-017:SQL Optimization-is not null and nvl

Shulou Source: shulou.com Published: 2022-06-01 21:26:21 10月02日 Update

Today, I am optimizing a section of sql. The original script is roughly as follows:

select a. field n from tab_a therea. field 2 is not null;

a. Field 2 adds index, but query speed is very slow,

The following changes were made:

select a. field n from tab_a awarenvl (a. field 2,'0')!= '0';

The speed increase was obvious.

What is the reason? It's simple, because is null and is not null invalidate the index of the field.

Although we all know which cases will make the index invalid, but sometimes inevitably affected by business requirements and consider not comprehensive enough, so sql optimization should be carried out at any time, at any time. Efforts to improve sql execution efficiency.

Tags: Field index a. speed obvious not enough business reason situation efficiency moment script requirement impact query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Shulou Information Redmi Shulou Technology