Saturday, 15 September 2012

How to optimize inserting 12K of JSON into database using PHP or Mysql or Laravel -


I am quite new to this, but I have a good job to work below, it includes Jason, Loop and When entering the database, if the player is present or not, then to check, if present, only update scores and bonuses if a new player then enters the new line.

My problem is the list of players that I have is very big around 10-15 (15000 for Players-1 player). When I am monitoring Laravel query logs for potential display hogs, I know that Looping is being followed once by the query of Forehope.

Since all 10-15K data is available and available, is there a way to run a large query instead of 10-15K personal questions when protected by the PDO placeholder from the $ score variable?

I was thinking of creating an array in PHP and then feed the array Mysql query, but then how will you secure it with a placeholder? Plus it will run many times in a day.

I am really confused to do this how to do the best, here is the code, the original is very big because it includes teams, location, IP address etc. and its ahead. But this is a trimmed example

unique key as database (id) $ score = '{"1": {"id": "1", "player": "1 "" "" ":" 2 "," player ":" 2 "," name ":" james "," score ":" 10.25 "," bonus ":" 2.10 "}," 2 ": {" id "": "John", "Score": "11.50", "Bonus": "1.10"}; $ Decoded = json_decode ($ score); Foreign currency ($ $ AS $ value decoded) { Include in $ update = DB :: Dot ("player, name, score, bonus) players (id, player, name, number, bonus) (duplicate: id, player :: name, number, bonus) Key Keyword Score = Price (Score), Bonus = Value (Bonus) ", Array (': Id' =>, $ value-> ID ': Player' = & gt ;, $ value- & gt ; Player ': name' = & gt ;, $ value- & gt; name ': score' =>, $ value- & gt; score ': bonus' = & gt ;, $ value- & gt; Bonus );}

To begin well, your INSERT looks like this It is an INSERT which is inserting 2 rows, and it is faster than 2 INSERTs

for larvail , The actions you showed Use the embedded function (see 'Inserting more than one record in a table')

It is not certain how this works behind the scenario, my guess is from foreign language Is faster


No comments:

Post a Comment