Quick Query NULL data in the table

Under normal circumstances, NULL values ​​are not into B-TREE index, so according to the time of taking the IS NULL queries are usually full table scan, if the record is less good, more records, the query can be very time consuming

Can be solved by creating an index

CREATE INDEX TABLE_OWNER.IX_TABLE_NAME_COL ON TABLE_OWNER.TABLE_NAME(COL,0) TABLESPACE TBS; 

COL is a column containing a NULL value

Forced to take the index by adding HINT

SELECT /*+INDEX(A IX_TABLE_NAME_COL)*/* FROM TABLE_OWNER.TABLE_NAME A WHERE COL IS NULL;

 

Guess you like

Origin www.cnblogs.com/monkey6/p/11514486.html