Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:09:55+00:00 2026-06-18T12:09:55+00:00

I am having to create a custom tool in .NET to data migrate and

  • 0

I am having to create a custom tool in .NET to data migrate and cleanse an existing system. And it also does some other things.

I have literally a table of around 2000 users and then for each of those users, they can have anything from 0 to 9,000 “customer accounts”

then for each of these users and their accounts, they will need to insert a menu system into another table for that user and account.

So I am having to go through all these objects created within the app, and execute an insert statement. The problem is, the performance is horrible. It took 3.5 hours to complete the inserts and each insert took around 3 seconds to complete…. pretty slow!

With the inserts, I am making sure that I dont insert duplicate data/make sure there isnt any existing duplicate data thus my insert statment:

 IF NOT EXISTS (SELECT ID FROM UserWebAccessLevel WHERE UserID = '{0}' AND CustomerID = '{1}' AND MenuID = {2}) BEGIN INSERT INTO [WebAccessLevel] (UserID, CustomerID, MenuID) VALUES ('{0}', '{1}', {2}) END 

doing this for each user, for their customers and for each menu item found within the app logic…. yeh, takes a long time.

im wondering how I can better enhance the performance of the insert statement?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:09:55+00:00Added an answer on June 18, 2026 at 12:09 pm

    Without an index on your table, the SELECT ID FROM... could be slowing things down, as SQL Server has to look at each record one by one and compare the IDs in the WHERE clause. By adding an index containing the three IDs, SQL Server will be able to (more-or-less) instantly locate an existing record when a WHERE clause specifies the three IDs.

    Assuming you are using SQL Server Management Studio:-

    • Right-click the table then click “Design”.
    • Right-click where the list of columns has appeared, then click “Indexes/Keys”.
    • in the next dialog that appears, click the Add button
    • In the list of properties on the r.h. side, find the one called “Columns” and click the box to the right of it. When you see the ellipses button (“…”) click that.
    • In the next dialog that appears, add your three ID columns.

    An index doesn’t have to be unique. In the “Indexes/Keys” dialog you get the option to specify whether it should be unique or not.

    The only other thing I can suggest checking is in your C#/VB code that executes the IF NOT EXISTS... SQL – make sure you aren’t opening and closing the connection each time. That will really slow things down!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble finding out how to create a custom transformer that can
I'm trying to create a custom dialog and I'm having some trouble. The custom
I am having a trouble while trying to create an entity with a custom
I’m having some problems with validation. I have created a custom validator called RequiredFieldRule
I'm having problems with some code to create a CDialog based window. The code
I see other questions for how to create custom events, but I'm not clear
Possible Duplicate: How to create a custom scrollbar on a div I'm having the
Instead of having to create a custom logger for TRACE, e.g. following what methods
I am trying to create a custom week counter but am having quite a
I've had to create a custom membership provider for my current ASP .Net project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.