Hi all,
I have given my code here and it's updating the database slowly.
Can you give me some other logic.
comparing talble has 3million rows. i shoud update 1million rows.
it's taking 4 seconds to load one row..it's very slow.
please help me
[PHP]<?php
mysql_connect("localhost", "root", "sudr");
mysql_select_db("adsd");
$query_1 = "select ID from al_ao";
$result_1 = mysql_query($query_1);
while($row = mysql_fetch_array($result_1)) {
$zinc_id = $row['ZincID'];
$query_2 = "select Mwt, Xlogp, apol, pol, donors, acceptor, psa, netcharge, rb, smiles from tproperty where zincId = '$zinc_id'";
$result_2 = mysql_query($query_2);
while($row1 = mysql_fetch_array($result_2)) {
$query_3 = "update al_ao set Mwt='$row1[Mwt]', Xlogp='$row1[Xlogp]', Apol='$row1[apol]', Pol='$row1[pol]', Donor='$row1[donors]', Acceptor='$row1[acceptor]', Psa='$row1[psa]', Netcharge='$row1[netcharge]', Rb='$row1[rb]', Smiles='$row1[smiles]' where ZincID = '$zinc_id'";
mysql_query($query_3) or die("couldn't insert values");
}
}
?>[/PHP]
3 1116
First that springs up is that you select field ID but fetches the data from field zincID. Must be a typo.
Secondly, you did not specify if there are any indexes used and, if so, on which columns.
Thirdly, have you ever investigated the use of the JOIN to get it together?
Ronald :cool:
Hi all,
I have given my code here and it's updating the database slowly.
Can you give me some other logic.
comparing talble has 3million rows. i shoud update 1million rows.
it's taking 4 seconds to load one row..it's very slow.
please help me
[PHP]<?php
mysql_connect("localhost", "root", "sudr");
mysql_select_db("adsd");
$query_1 = "select ID from al_ao";
$result_1 = mysql_query($query_1);
while($row = mysql_fetch_array($result_1)) {
$zinc_id = $row['ZincID'];
$query_2 = "select Mwt, Xlogp, apol, pol, donors, acceptor, psa, netcharge, rb, smiles from tproperty where zincId = '$zinc_id'";
$result_2 = mysql_query($query_2);
while($row1 = mysql_fetch_array($result_2)) {
$query_3 = "update al_ao set Mwt='$row1[Mwt]', Xlogp='$row1[Xlogp]', Apol='$row1[apol]', Pol='$row1[pol]', Donor='$row1[donors]', Acceptor='$row1[acceptor]', Psa='$row1[psa]', Netcharge='$row1[netcharge]', Rb='$row1[rb]', Smiles='$row1[smiles]' where ZincID = '$zinc_id'";
mysql_query($query_3) or die("couldn't insert values");
}
}
?>[/PHP]
I think a more advanced SQL update is necessary: -
UPDATE tproperty s, al_ao u
-
SET
-
u.Mwt = s.Mwt,
-
u.Xlogp = s.Xlogp,
-
u.Apol = s.Apol,
-
u.Pol = s.Pol,
-
u.Donor = s.Donor,
-
u.Acceptor = s.Acceptor,
-
u.Psa = s.Psa,
-
u.Netcharge = s.Netcharge,
-
u.Rb = s.Rb,
-
u.Smiles = s.Smiles
-
WHERE
-
tproperty.zincID = <zincid>
-
AND al_ao.zincID = tproperty.zincID
-
motoma: Thank you for helping out.
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is...
|
by: Aaron |
last post by:
How would code obfuscation affect performance? in .net C#
|
by: SAN3141 |
last post by:
There doesn't seem to be consensus about when to put code in the
database or in the middle tier. There was a long discussion about this
in an Oracle newsgroup (message ID:...
|
by: Joe Fallon |
last post by:
I have some complex logic which is fairly simply to build up into a string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.
My...
|
by: tshad |
last post by:
I am just trying to decide whether to split my code and uses code behind. I
did it with one of my pages and found it was quite a bit of trouble.
I know that most people (and books and articles)...
|
by: tshad |
last post by:
Many (if not most) have said that code-behind is best if working in teams -
which does seem logical.
How do you deal with the flow of the work?
I have someone who is good at designing, but...
|
by: John Rivers |
last post by:
Hello,
What good reason there is for not allowing methods in ASPX pages I
can't imagine, but here is how to get around that limitation:
(START)
<body MS_POSITIONING="FlowLayout">
<form...
|
by: lawrence k |
last post by:
The following function is way too slow. If anyone has any suggestions
about how to speed it up, I'd be grateful for them. We have to call
this function 36 times on one page, and I think each time...
|
by: shuisheng |
last post by:
Dear All,
I was told that unit test is a powerful tool for progamming. If I am
writing a GUI code, is it possible to still using unit test?
I have a little experience in using unittest++. But...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |