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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:10:09+00:00 2026-05-26T07:10:09+00:00

I have an sql server 2008 db table that holds links to articles. My

  • 0

I have an sql server 2008 db table that holds links to articles.
My app routine is that every ~1-10 seconds i get a list of 10-100 new articles that contain a url,
and what i need to do is check every article’s url and if it doesn’t exist on the db i will add it.

How i do it know :
first thing – i made a unique index for the url so no matter what – i won’t have the same url more than once (of course i normalize the url e.g cut it’s ‘http://www.’ prefix etc before i insert it).

the ‘InsertArticles’ method is something like this:

  1. Open a transaction
  2. for each link – check (using the transaction) if its url exists in the db
  3. for each unexisting link – add the link (of course,using the same transaction)
  4. execute and close the transaction + handle transaction/general exceptions

the thing is – most of the time it works very fast (0.05-0.2 secs) for about 10-20 or so links..
but sometimes it gets much slower – it can even take 50 secs to call this method with 50 articles.

So 2 questions here –

  1. is what I do ok ? should i use transactions for this kind of a job?
  2. what alternatives do i have ? maybe insert if not exists ?

i was also thinking – why not just ‘brute insert’ the new articles to the db – meaning, i will try to insert all the input url’s to the db and I will let sql server throw an exception for those urls that already exist there..

Maybe using a stored proceude to do all of this can enhance perfomance ?

anyway any help would be appreciated.

  • 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-05-26T07:10:10+00:00Added an answer on May 26, 2026 at 7:10 am

    You could try the MERGE-statement to combine the SELECT and INSERT into one statement:

    -- Table "links" with column "url"
    MERGE links AS L
    USING (SELECT url FROM links WHERE url = @url) AS I (url)
    ON (L.url = I.url)
    WHEN NOT MATCHED THEN INSERT (url) VALUES (@url)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in a sql server 2008 database that contains bunch of
I have a table which contains my ads that can be searched in sql-server-2008.
I have a SQL Server 2008 database table that uses uniqueidentifier as a primary
I have data in a SQL Server 2008 table that looks like this: I
I have a SQL Server 2008 table with a DateTime column that I'd like
I have a SQL Server 2008 database with a table that contains a FILESTREAM
I'm using SQL Server 2008. I have a database table that looks like this
I have a table that stores stock ticks in sql server 2008. It is
I have a field in my SQL Server 2008 table that is auto number
I have a SQL Server 2008 R2 table with nvarchar(4000) field. Data that stores

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.