What is the cost of indexing multiple db columns?

后端 未结 7 1433
孤街浪徒
孤街浪徒 2020-12-19 07:02

I\'m writing an app with a MySQL table that indexes 3 columns. I\'m concerned that after the table reaches a significant amount of records, the time to save a new record wi

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 07:48

    Nothing for select queries, though updates and especially inserts will be order of magnitudes slower - which you won't really notice before you start inserting a LOT of rows at the same time...

    In fact at a previous employer (single user, desktop system) we actually DROPPED indexes before starting our "import routine" - which would first delete all records before inserting a huge number of records into the same table...

    Then when we were finished with the insertion job we would re-create the indexes...

    We would save 90% of the time for this operation by dropping the indexes before starting the operation and re-creating the indexes afterwards...

    This was a Sybase database, but the same numbers apply for any database...

    So be careful with indexes, they're FAR from "free"...

提交回复
热议问题