Decision when to create Index on table column in database?

后端 未结 3 831
臣服心动
臣服心动 2021-01-30 03:29

I am not db guy. But I need to create tables and do CRUD operations on them. I get confused should I create the index on all columns by default or not? Here is my understanding

3条回答
  •  天命终不由人
    2021-01-30 03:58

    but update of column value wont have any impact on index value. Right?

    No. Updating an indexed column will have an impact. The Oracle 11g performance manual states that:

    UPDATE statements that modify indexed columns and INSERT and DELETE statements that modify indexed tables take longer than if there were no index. Such SQL statements must modify data in indexes and data in tables. They also create additional undo and redo.


    So bottom line is when my column is used in join between two tables we should consider creating index on column used in join but all other columns can be skipped because if we create index on them it will involve extra cost of updating index value when new value is inserted in column. Right?

    Not just Inserts but any other Data Manipulation Language statement.

    Consider this scenario . . . Will index help here?

    With regards to this last paragraph, why not build some test cases with representative data volumes so that you prove or disprove your assumptions about which columns you should index?

提交回复
热议问题