I'm really indebted to you... Your ideas triggered me to actually learn so many new things... The culprit was in the trace table. When i was querying that table, it was returning many results or should I say duplicate results... And that was the reason it was slowing down everything... The way I figured this out is that I put a couple of echo statements in my script and observed where the program was slowing down... And that made the trick...!
I have one more doubt: Lets take the structure:
asn1 | ip1 | asn2 | ip2
All are integer fields... I want to actually delete all the duplicate rows in the table.
Actually, I still didn't specifically commit anything... I just used a single insert statement in a loop. Other than that I haven't done anything special and yeah I improved the queries too... And regarding your suggestion, what do I do when there's no rowid in my table?
Last edited by Legend986; 11-02-2007 at 02:55 AM..
Sorry that was a grammar typo... Corrected now... I'm doing it in the following way:
Code:
for($i=2;$i<2749750;$i++) {
if($i == 2) {
//This is the first row. So fetch it as usual and break out of the loop
$sql_prev = "SELECT ip,gid FROM trace WHERE ID=".($i-1);
$result_prev = mysql_query($sql_prev) or die(mysql_error());
$row_prev = mysql_fetch_assoc($result_prev);
continue;
}
//If $i is not 2 then we fetched the previous row. So lets compare now
$sql_cur = "SELECT ip,gid FROM trace WHERE ID=".$i;
$result_cur = mysql_query($sql_cur);
$row_cur = mysql_fetch_assoc($result_cur);
$sql_prev_asn = "SELECT asn FROM asn_number WHERE ip_address=$row_prev[ip] LIMIT 1";
$result_prev_asn = mysql_query($sql_prev_asn);
$row_prev_asn = mysql_fetch_assoc($result_prev_asn);
$sql_cur_asn = "SELECT asn FROM asn_number WHERE ip_address=$row_cur[ip] LIMIT 1";
$result_cur_asn = mysql_query($sql_cur_asn);
$row_cur_asn = mysql_fetch_assoc($result_cur_asn);
if(($row_prev_asn['asn'] != $row_cur_asn['asn']) && ($row_prev['gid'] == $row_cur['gid'])) {
$sql = "INSERT INTO br(asn1,ip1,asn2,ip2) VALUES('$row_prev_asn[asn]','$row_prev[ip]','$row_cur_asn[asn]','$row_cur[ip]')";
$result = mysql_query($sql) or die(mysql_error());
}
$row_prev = $row_cur;
}
So, I'm not using any explicit commit statements... I'm writing this code in PHP. And well, I'm not using Oracle. I'm using MySQL...
Hi,
I'm on a Raspberry Pi with Raspbian Wheezy.
I urgently need to get MySQL running with PHP, but I get an error.
For example:
$con=mysql_connect("127.0.0.1","root","******","ids");
gives
PHP Fatal error: Call to undefined function mysql_connect()
So, I found I needed to install some... (2 Replies)
Hello,
While I was interpretation the PHP manual on database security the recent past, it said that you should by no means connect to the database as the super user but rather as one more user with more limited options.
My question is:
How do you generate new users and set access... (2 Replies)
Hi,
I have two websites:
website1.com and website2.com
I didn't write either but have successfully moved all the files from website1.com to website2.com
I (thought) I installed all the correct php modules and website2 is mostly up and running. However, my boss found that when we go to a... (15 Replies)
Hi,
The php is not able to connect into my mysql database. But i can able to connect by manually.
I think that I have missed some points.
Please guild for the same.
Thanks,
Mani (1 Reply)
Hello every one
i have question i want to build DATAbase using PHP as interface
i use shell to access to linux . i have in linux psql and SQLplus
i'll call all html files that has db tabels from shell directory.
what should to do before design php pages. can build the database sql design... (3 Replies)
Hi All,
I have a problem with my database having lots of 'stale' slow_queries. I think the problem may be because of the following code:
$numresults=mysql_query("select * from links where catagory=".$catagory." order by linknum");
$numrows=mysql_num_rows($numresults);
I believe this... (4 Replies)
Okay, I'm new to this PHP and MySQL stuff, so help would be VERY much appreciated. :)
On my iMac runnning Panther, it has MySQL and PHP installed.
Yet when I view a PHP file from the iMac or another computer at my house, I get the source code.
What's wrong? (11 Replies)
I want to design a database, using mysql as a backend, and PHP as the frontend, I wanna be able to easily build forms in PHP to communicate with MySQL, is there any programs that will allow this, I really dont want to program all the forms by hand..
thankyou (2 Replies)