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 8054289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:06:51+00:00 2026-06-05T08:06:51+00:00

For a web application where deleting records happens often, what is the best, if

  • 0

For a web application where deleting records happens often, what is the best, if we take performance into consideration?

  • check if the record has any reletaionship with other tables and prevent the user from deleting.

    ex : the query will be like this

     if not exist(select * from table1 where tableX_id = @id) and 
           not exist(select * from table2 where tableX_id = @id)
           ...
        then 
           delete from tableX where id = @id 
    

    or

  • perform the delete and let the RDBMS rais an error due to the foriegn key constraint

      try{
           Service.DeleteRecord(id)
      }catch{
           Handle the error here
      }
    

    in this case the query will be simple

     delete from TableX where id = @id
    
  • 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-05T08:06:51+00:00Added an answer on June 5, 2026 at 8:06 am

    If the goal is to prevent rows from being deleted only in the case where actually running the delete would yield an error because it is referenced by other tables, then I suggest you check for the violation before letting SQL Server check for you. I’ve done some testing on this and letting SQL catch the error or just using TRY/CATCH can be more expensive if you expect even a moderate amount of failures. With the proper indexes in place, the additional cost of performing the check is negligible; however the cost of NOT doing the check is certainly LESS negligible.

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

Sidebar

Related Questions

My web application is a product which has to deploy to a variety of
My web application has got a lot of service tables/entities, such as payment_methods ,
In my web application, I was dynamically adding/deleting rows from my HTML table using
I am a little confused here, building a web application which has tab sheet.
I am developing a small email web application in JSP/Javascript/html. It has a logout
The web application I'm working on serves up images with URLs like /image?name=a.gif. Pages
my web application supposed to send email reminders in some point it will send
My web application operates only over SSL and sets a time limited cookie for
My web application stores URL segments in a database. These URL segments are based
My web application consists of library type system where books have due dates. I

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.