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

  • Home
  • SEARCH
  • 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 7019903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:14:49+00:00 2026-05-27T23:14:49+00:00

Is it okay to hit many Duplicate row on insert when inserting into the

  • 0

Is it okay to hit many “Duplicate row on insert” when inserting into the sql db or is there a better way?

I am downloading “comments” from my server and displaying them in a listview on my android phone..

Here is how I do it:

1 – Whenever I display the listview, I fetch that last 15 comments via xml from the server..

2 – I insert the comments into a local sql database on the phone

3 – I update the listview by using an adapter that loads the data from the local sql database.

Every 30 seconds I am repeating steps 1, 2 and 3.. I also repeat steps 1, 2, and 3 when the activity hits onResume…

Unless another android client has uploaded a new comment, all comments fetched from server are duplicates and inserting them into the db returns an SQLConstraintException because I don’t allow duplicates of the same comment.

Is this okay? I am throwing this exception for 10-15 rows every 30 seconds.. Is there a better way that wont hurt performance? I don’t see the point of checking if the row exists before insert, since that will surely be slower.. I could potentially pass a variable to the server when I query it, telling it what my newest comment is..

I’m sure many many people have reached this crossroads. Where should we go from here?

Thanks for the discusson..

  • 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-27T23:14:49+00:00Added an answer on May 27, 2026 at 11:14 pm

    If your server’s db has a sequential, incremental key then yes, I would just query with an additional condition “…AND SeqIdField > [my last id]”. If no records are returned then you just reset your timer and wait to query again.

    Even if there’s no sequential id but you can get records inserted after a particular date/time then just make sure that date/time is included in your results and pass the latest one back in as a parameter. If you don’t want / need to store that date/time on your local device then just save the latest somewhere so you know where to pick back up when your app runs again.

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

Sidebar

Related Questions

Okay, so I'm doing my first foray into using the ADO.NET Entity Framework. My
Currently migrating from SQL Server to PostgreSQL and attempting to improve a couple of
Okay, so I'm currently developing an iphone app that I plan to take into
Possible Duplicate: C# okay with comparing value types to null I was working on
Okay, I'm creating a program from a single class, let's call it John class.
Okay, I've looked all over the internet for a good solution to get PHP
Okay, so I'm running a small test webserver on my private network. I've got
Okay so im working on this php image upload system but for some reason
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, I've seen but haven't programmed in C# before. You can assume I'm competent

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.