The goal is to create a database with millions of X and Y records (these are coordinates, values ​​from 0 to 1000).

What I thought of :

$x = 0; $y = 0; while ($y <= 1000) { $result = mysql_query("INSERT INTO map (x,y) VALUES('$x','$y')"); $y++; if ($y > 1000) { $x++; $y = 0; } } 

What did not work out? Write to the database is only up to 29th record.

Question. How to make my decision work (if it is possible and adequate)? Or how else can it be done?

Thank you in advance.

  • Why do you need such a base? - Ale_x
  • better do a store where you specify the number of iterations and voila call as parameters !!! - Vfvtnjd

2 answers 2

In my opinion, the base does not withstand such pressure. Try every 20 entries to sleep() ;

What is the problem to create it directly through phpmyadmin ? That is, first write a lot of requests (looping in PHP to output "INSERT INTO..." ), and then massively execute in the phpmyadmin interface.

  • manually write and massively execute 1,000,000 queries ??? the base will withstand)))) as well as withstand just 1,000,000 requests from the program loop - ale

so the code is non-working for you - there is a restriction on the growth of only the $ y variable, and where are the restrictions on the growth of the $ x variable?

 $x = 0; $y = 0; while ($y <= 1000 & $x<=1000) { $result = mysql_query("INSERT INTO map (x,y) VALUES('".$x."','".$y."')"); $y++; if ($y > 1000) { $x++; $y = 0; } } 
  • Well, yes, an infinite loop. Where did the number 29 in the question come from - it is not clear - ale
  • The cycle is not endless. As soon as Y fails to satisfy the condition, everything will stop ($ y <= 1000 & $ x <= 1000) - azhirov1991