Jump to content

need your suggestion select & insert or delete & insert :-)


jaikar

Recommended Posts

hi,

 

i need to insert a record in a table when ever a particular user clicks that link, to track if he clicked that link, that record should be inserted only once. when he clicks it again it should not insert, to do this i have 2 options listed below

 

1. make the select query and check if that particular record is available, if npt available insert the new record,.. if available, dont insert

2. delete the existing record and insert the new one.

 

of the above 2 which will be faster if the records  are so many .... according to the applications use, most of the time only a new record is inserted, its expected that most of the user will click the link only once. in some cases user may click the link more than once also. which one you will suggest.... please advise

 

Thanks in advance

 

Jaikar

Well, the select thingy can be pretty fast. If you indexed your table, and add LIMIT 1 at the end of the query, it should be really fast. But I guess it wont make a big difference, although I'd prefer the select tool. Because when you have to replace a row, it has to find it first anyway, and than hes going to replace it, while it doest have to replace it...

 

And if most users only click once...not very sure about this, I never figured a site where I could view all statistics about whats faster etc...

 

Full-Demon

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.