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. General Programming
  3. Design and Architecture
  4. I have sql server database insert operation is very slow

I have sql server database insert operation is very slow

Scheduled Pinned Locked Moved Design and Architecture
databasesql-serversysadminhelp
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.
  • K Offline
    K Offline
    kali siddhu
    wrote on last edited by
    #1

    I have sql server database insert operation is very slow. I am moving data from stage tables--> temporary tables-->Master tables --> Data warehouse tables. Loading the data from stage tables to master tables it is very slow due primary key, foreign key constraints and non clustered index. I am trying to drop the non clustered index before loading the data but there is no use. I am trying to drop the primary key getting issue with foreign key.

    M 1 Reply Last reply
    0
    • K kali siddhu

      I have sql server database insert operation is very slow. I am moving data from stage tables--> temporary tables-->Master tables --> Data warehouse tables. Loading the data from stage tables to master tables it is very slow due primary key, foreign key constraints and non clustered index. I am trying to drop the non clustered index before loading the data but there is no use. I am trying to drop the primary key getting issue with foreign key.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Be very sure you are only doing and insert, not an update. We created a stored proc that removed all indexes except the PK on the destination tables. applied the insert and then rebuilt the indexes. CAVEAT your data MUST be clean as you lose all referential integrity checking.

      Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

      K 1 Reply Last reply
      0
      • M Mycroft Holmes

        Be very sure you are only doing and insert, not an update. We created a stored proc that removed all indexes except the PK on the destination tables. applied the insert and then rebuilt the indexes. CAVEAT your data MUST be clean as you lose all referential integrity checking.

        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

        K Offline
        K Offline
        kali siddhu
        wrote on last edited by
        #3

        If i drop non clustered index will i any benefit on insertion? If i found matched record i am updating otherwise insert.

        M 1 Reply Last reply
        0
        • K kali siddhu

          If i drop non clustered index will i any benefit on insertion? If i found matched record i am updating otherwise insert.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          kali siddhu wrote:

          If i found matched record i am updating otherwise insert

          Right there is your problem, for every record you are checking for an existing record and when you do the update the system has to check referential integrity. Split your data into 2 set, those to be inserted and those to be updated. OR delete the records to be updated and insert all records. This may not be viable as it will break existing RI.

          Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

          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