php - Write data from file to database with updating old data -


I have a file with 500-5000 lines that I want to save in my database. The difficulty here is that I need to update the old data too - not just inserting.

So I tried different ways:

  • Line
  • Using simple array buffer, write 100 lines simultaneously
  • Load data INFILE (very fast but overwrite / ignore all)

    I had difficulty writing 500 lines in the database using the first method I needed the whole process ~ 25-30sec which is a long way both the other Dian fast (only 1-2 seconds) but overwrite the old data that is required to update me.

    This update includes a simple increase of counters and a new timestamp. So the first approach's query looks like this:

      INSTERT 'latest' (`hash`,` first_tree`, 'last_tree`, `count_trays`,` sender`) value (: hash, : First,: last, 1, sender) Key update of duplicate `count_tries` =` count_tries` + 1, `last_try` = = last2   

    but I do not know the possibility of joining 100 Having, too (which I tried to do in my second view)

    Do you know the possibility to use this line-per-line-query to speed up or use on DUBLICATE

    < div>

    "post-text" itemprop = "text">

    The file should be in the table of the original table Load with the same schema. Revert:

      In the latest (`hash`,` first_tree`, 'last_tree`,' count_trays`, 'sender'] select INSERT 'hash', 'first_tree', 'last_tray' Top updates of DMPACCT on DPLTTest from coupon_trees`, `sender`, count_tries = count_tries + 1, last_try = value (last_tree)   

    duplicate key update section on a , value (call) contains the value that is stored in that column if it was not a duplicate.

Comments

Post a Comment

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -