Jump to content


duplicate records

  • Please log in to reply
2 replies to this topic

#1 khefner

  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 February 2006 - 12:24 AM

I have a little mysql database that is taking in data from a php input form. What is happening is users are inputing data more than once, creating duplicate records in the database. I think its happening because they are getting impatient waiting for the "submission completed" page to display,and they are hitting the submit button a second time.
What is the best way to eliminate duplicate entries from occuring?

My second question is regarding the time it takes to update the database. It used to take about 10 seconds to update the data from my php form. (Its only text) It now takes about 30 to 45 sec. Could there be a issue with the database now that it has gotten a little bigger that is causing access to slow? It has about 175 records, all of which are text only. (about 12 fields per record)

When I display the contents of the database on a webpage it updates in about 5 to 7 seconds, so it seems the slowdown occurs only when I write to the database. I recall that Microsoft Access had a database optimize function that reduced the size of the file. Perhaps I have to do something like that with the mysql database to speed it up?

#2 wickning1

  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 17 February 2006 - 04:31 AM

A well-written application should never take more than a second to run, unless you are doing some serious data crunching. Correct me if I'm wrong but it sounds like you are not indexing your database at all. If that's the case, you might want to do a little reading.

#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 February 2006 - 08:35 AM

Agreed, but it's hard to time PHP scripts, since PHP and browser overhead is involved. It's trivial to profile the MySQL execution time _within_ the script, though. Either way, 4-5 seconds is reasonable for any page load, so 5-7 is not too far off.

WRT duplicate records, you can easily disable the submit button onsubmit, check the sessionUID / cookie to make sure they haven't submitted, etc.. It's non-trivial to do this properly on the DB end.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users