I used to be confused about why index indexing cannot improve efficiency. Later, I found in many books and forums that there are three types of indexes. The default index is the B-tree index. This type of index has no advantage in dealing with repeated columns, for example, the Gender column has only two values (a third value is not excluded. This high degree of repetition is listed in many of my usual production systems, such as the operator's Administrative Region column. in Xi'an, there are only several administrative districts, such as urban, residential, zhouzhi, and Lantian, this type of repetition is highly repeated in tables of millions or even tens of millions. In this case, the bitmap index should be used.
The following is an experiment on my own machine: 1. First, create three tables. table1 is from dba_objects where object_type is table and index, and then use the following statement to enlarge the table: www.2cto.com
BEGIN
For I IN 1 .. 10 LOOP
Insert into TABLE1
SELECT * FROM TABLE1;
COMMIT;
End loop;
END;
2. Create table2 and table3 from table1.
3. table1 does not CREATE an INDEX, table2 creates a B-tree INDEX, table3 creates a bitmap INDEX, and object_type: CREATE INDEX idx_1 ON table2 (object_type ); create bitmap index idx_2 ON table3 (object_type); then use this SQL statement to query data and view their execution plan: www.2cto.com select * from tablen where object_type = 'index '; originally intended to use autotrace, but my local machine can not stand so big SQL, will report ora-04030 error, so here with explain. Obviously, indexes are not used in the execution plan of table 2 that uses B-tree indexes. Instead, full table scan is adopted like table1. The execution plan of table 3 can be stuck, and the cost is only 11611, that is, less than half of the two above. It can be seen that the effect is still very good. As the amount of data increases, the index effect will be reflected. It is said that Bitmap indexes will be relatively small: the fact is true. I think it is also necessary to conduct an experiment to test the efficiency of using Bitmap indexes, B-tree indexes, and queries without indexes on a column similar to a serial number. But I am in a bad mood today, so let's talk about it over the weekend.