--- url: "https://use-the-index-luke.com/sql/dml/update" titulek: "The more columns you update, the slow it is" h1: "Update" popis: "UPDATE must keep all indexes in sync. Fewer indexes makes UPDATE faster. Fewer columns update also." jazyk: "en" kanonicka: "https://use-the-index-luke.com/sql/dml/update" drobecky: ["Table of Contents", "Modifying Data"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 05:14:51" znaku: 2786 slov: 425 kodovani: "utf-8" sha256: "173c85b87101136f3774d60b14291379f58ffec4c71280d47deca03cb50d0abc" --- by [Markus Winand](//winand.at/home). # Update --- An `update` statement must relocate the changed index entries to maintain the index order. For that, the database must remove the old entry and add the new one at the new location. The response time is basically the same as for the respective `delete` and `insert` statements together. The `update` performance, just like `insert` and `delete`, also depends on the number of indexes on the table. The only difference is that `update` statements do not necessarily affect all columns because they often modify only a few selected columns. Consequently, an `update` statement does not necessarily affect all indexes on the table but only those that contain updated columns. Figure 8.3 shows the response time for two `update` statements: one that sets all columns and affects all indexes and then a second one that updates a single column so it affects only one index. Figure 8.3 Update Performance by Indexes and Column Count The `update` on all columns shows the same pattern we have already observed in the [previous sections](/sql/dml/insert): the response time grows with each additional index. The response time of the `update` statement that affects only one index does not increase so much because it leaves most indexes unchanged. To optimize `update` performance, you must take care to only update those columns that were changed. This is obvious if you write the `update` statement manually. ORM tools, however, might generate `update` statements that set all columns every time. Hibernate, for example, does this when disabling the [*dynamic-update mode*](https://docs.hibernate.org/orm/6.2/userguide/html_single/#pc-managed-state-dynamic-update). Since version 4.0, this mode is enabled by default. When using ORM tools, it is a good practice to occasionally enable query logging in a development environment to verify the generated SQL statements. The tip entitled [“*Enabling SQL Logging*”](/sql/join/nested-loops-join-n1-problem#tip-orm-log-sql) has a short overview of how to enable SQL logging in some widely used ORM tools. #### Think About It Can you think of a case where `insert` or `delete` statements do not affect all indexes of a table? *You can’t learn everything in one day. Subscribe the newsletter via **[E-Mail](https://winand.at/lists)**, **[Bluesky](https://bsky.app/profile/winand.at)** or **[RSS](/blog/feed)** to gradually catch up. Have a look at [modern-⁠sql.com](https://modern-sql.com) as well.* ## About the Author Markus Winand provides insights into SQL and shows how different systems support it at [modern-sql.com](https://modern-sql.com). Previously he made [use-the-index-luke.com](https://use-the-index-luke.com), which is still actively maintained. Markus can be hired as trainer, speaker and consultant via [winand.at](https://winand.at).