473,508 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mysql update large table too much long time

232 New Member
I have two tables in database
table1 consisting of student data 4,00,000 records
table2 consisting of student examination center with roll nos range-800 records
I have to search roll no in range and then allocate center to it
i tried all methods but failed
first I tried to update by join it took infinite time to execute and resulted in browser hang
then I tried to go to student data through center allocation data and then executed update. loop has to execute 800 times but after 1:30 hours it gives time execution exceeds error.
Please help me to find a quickest method to do it
METHOD1-HANGS BROWSER
Expand|Select|Wrap|Line Numbers
  1. UPDATE STUDENTDATA INNER JOIN CENTER ON STUDENTDATA.SCH=CENTER.SCH SET EXAMCENTER = EXMCENTER
  2. WHERE ROLLNO>=ROLLNO_FROM1 AND ROLLNO<=ROLLNO_TO1;
METHOD 2-ERROR AFTER 1:30 HOURS OF EXECUTION
Expand|Select|Wrap|Line Numbers
  1. ?php 
  2. //$myfile = fopen("cenfil17.txt", "w") or die("Unable to open file!");
  3. include 'include/conn.php';
  4. $sql = "update studentdata set examcenter=''" ;
  5. $result = $conn->query($sql);
  6. //SET  innodb_lock_wait_timeout = 5000; 
  7. //ini_set('innodb_lock_wait_timeout', '5000');
  8.  
  9.         $pSCHOOL="1";$vSCHOOL="4";
  10.         $sql = "select * from CENTER  order by SCHOOLNO2" ;
  11.         $result = $conn->query($sql);
  12.         ini_set('memory_limit', '-1');
  13.         while($row = $result->fetch_assoc()) {
  14.         $sql1 = "UPDATE studentdata  SET examcenter = '".$row["exmcenter"]."' WHERE SCH='".$row["SCH"]."' AND ( CAST(rollno AS UNSIGNED) BETWEEN " . $row["SERIAL_FROM"]." AND ". $row["SERIAL_TO"]." OR CAST(rollno AS UNSIGNED) BETWEEN " . $row["SERIAL_FROM1"]." AND ". $row["SERIAL_TO1"]. ")"  ;
  15.         ECHO $sql1."<BR/>";
  16.         //EXIT;
  17.         $result1 = $conn->query($sql1);    
  18.  
  19. }
  20.  
  21.  
  22. //fclose($myfile);
  23. $conn->close();
  24. ?>
Nov 1 '16 #1
3 2086
Dormilich
8,658 Recognized Expert Moderator Expert
Please help me to find a quickest method to do it
use indexes
Nov 2 '16 #2
kkshansid
232 New Member
i tried index then
run method -1 that is bulk update method
but browser still browser hangs
Nov 3 '16 #3
Dormilich
8,658 Recognized Expert Moderator Expert
then you need to let MySQL explain you the query.
Nov 3 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
18168
by: Karaoke Prince | last post by:
Hi There, I have an update statement to update a field of a table (~15,000,000 records). It took me around 3 hours to finish 2 weeks ago. After that no one touched the server and no...
1
4683
by: Chris | last post by:
Can anyone help me on this one? I have a giant (couple thousand rows) HTML table. Im trying to modify some of the cells innerHTML and/or innerText, but it is taking a VERY long time to do so....
2
2294
by: Shashikant Kore | last post by:
Hi, I am using MySQL for a table which will have 100M+ records, avg length of records being 130 bytes. When the number of records reach approx. 25M (and the file size close to 4GB), the rate of...
11
27175
by: dfurtney | last post by:
SQL Server 7/2000: We have reasonably large tables (3,000,000 rows) that we need to add some indexes for. In a test, it took over 12 hours to CREATE a new INDEX against this table. One of us...
1
6192
by: Good Man | last post by:
Hi there I'm developing a large web application. Part of this web application will be storing numerical chart data in a MySQL table - these numbers will be already calculated, and are just being...
3
1965
by: Eitan | last post by:
Hello, I have run a long transaction on the DB (sql server) For some long transaction I have got the following message : What can I do in order to run it properly ? Error Type:
4
2053
by: Brian | last post by:
Hello, I have a vb.net web app that I am doing reads and adds to a database. Everything works fine and happens instantly. I recently added an update and it takes a long time to finish. I was...
1
2379
by: murray | last post by:
Large table performance problem with MYSQL performance with ASP.NET I am doing some benchmarking of an application using MYSQL under Windows and I confused about the results. Environment...
0
1333
by: OctoTools | last post by:
Large table performance problem with MYSQL performance with ASP.NET I am doing some benchmarking of an application using MYSQL under Windows and I confused about the results. Environment...
7
9765
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.