Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Delete Insert VS. Update Insert

Delete Insert VS. Update Insert

Scheduled Pinned Locked Moved Database
visual-studioperformancequestionannouncementlounge
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M H 1 2 3
    wrote on last edited by
    #1

    I have a nightly process (SISS Package) that will do data dump from several tables used for order entry to tables used for reporting. My question is whether there is a general rule from a performance stand point that says wether it is faster to do an update on existing rows in the reporting table then insert new ones or just delete for a range then do a bulk insert. The number of records being updated/inserted would be anywhere from 2 records to 150,000. Assume that appropriate indexes will be used for deletes and updates.

    H 1 Reply Last reply
    0
    • M M H 1 2 3

      I have a nightly process (SISS Package) that will do data dump from several tables used for order entry to tables used for reporting. My question is whether there is a general rule from a performance stand point that says wether it is faster to do an update on existing rows in the reporting table then insert new ones or just delete for a range then do a bulk insert. The number of records being updated/inserted would be anywhere from 2 records to 150,000. Assume that appropriate indexes will be used for deletes and updates.

      H Offline
      H Offline
      Hesham Amin
      wrote on last edited by
      #2

      I think It's better to update to avoid fragmentation in index. Unless you drop and rebuild the index after each bulk operation.


      Hesham A. Amin blog

      M 1 Reply Last reply
      0
      • H Hesham Amin

        I think It's better to update to avoid fragmentation in index. Unless you drop and rebuild the index after each bulk operation.


        Hesham A. Amin blog

        M Offline
        M Offline
        M H 1 2 3
        wrote on last edited by
        #3

        Thanks for the information. Do inserts always cause fragmentation or is this more of a problem with bulk inserts?

        H 1 Reply Last reply
        0
        • M M H 1 2 3

          Thanks for the information. Do inserts always cause fragmentation or is this more of a problem with bulk inserts?

          H Offline
          H Offline
          Hesham Amin
          wrote on last edited by
          #4

          They always do if the new records are inserted between existing record unless there is a space according to a previously deleted record. You can minimize this effect by configuring fill factor and padding for indexes. If you use the clustered index as an identity column, fragmentation should not occur. So there is no very direct do and don't in this case. You need to study your database structure carefully.


          Hesham A. Amin blog

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups