|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
is it normal for mysql to take 14+ seconds to do 10k inserts?
is it normal for mysql to take 14+ seconds to do something simple like (pseudecode) for x = 10000 to 20000; mysql_query(insert into users (muser) values ($x)) ???
muser is varchar, length 5, non primary (it is the only column in the table) I am on a AMD Athlon 64 3500+ PC with 1gb ram.. this is all being done locally the exact code im using is below Code:
$dbcnx = mysql_connect('localhost','xxxxx', 'xxxxx');
mysql_select_db("testtable", $dbcnx);
for ($i = 10000; $i <= 20000; $i++) {
mysql_query("insert into users (muser) values ('$i')");
}
__________________
ICQ: 298-523-037 |
|
|
|
|
|
#3 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
about 400KB while its inserting
the cpu mysql uses is around 30% during the inserts.. ![]()
__________________
ICQ: 298-523-037 |
|
|
|
|
|
#5 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
is it normally much faster?
__________________
ICQ: 298-523-037 |
|
|
|
|
|
#6 |
|
Pounding Googlebot
Industry Role:
Join Date: Aug 2002
Location: Canada
Posts: 34,504
|
I'm guessing by the code you're doing this in perl. Perl has always been very slow for me in doing basic sql operations such as adds/deletions. It's extremely fast to use mysql directly to import the data from a file if this is possible in your application.
WG
__________________
I play with Google. |
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
wow.. it takes <2 seconds on a linux server
im using windows, and i am desperately trying to figure out why mysql is so 700% slower using the same code..
__________________
ICQ: 298-523-037 |
|
|
|
|
|
#8 | |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
Quote:
|
|
|
|
|
|
|
#9 |
|
Pounding Googlebot
Industry Role:
Join Date: Aug 2002
Location: Canada
Posts: 34,504
|
Perl too. Maybe its Windows that really makes it all slow
WG
__________________
I play with Google. |
|
|
|
|
|
#10 |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
the problem is mysql commits after each insert so you're better running a combined insert:
Code:
$dbcnx = mysql_connect('localhost','xxxxx', 'xxxxx');
mysql_select_db("testtable", $dbcnx);
$cmd = "insert into users (muser) values ";
for ($i = 10000; $i <= 20000; $i++) {
$cmd .= "($i),"
}
$cmd .= "(20001)"
mysql_query($cmd);
|
|
|
|
|
|
#11 |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
I meant the code he posted is php
|
|
|
|
|
|
#12 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
figured it out =)
looks like it was the table structure.. INNODB is 7-8x faster than InnoDB (at least on windows anyway)
__________________
ICQ: 298-523-037 |
|
|
|
|
|
#13 |
|
Pounding Googlebot
Industry Role:
Join Date: Aug 2002
Location: Canada
Posts: 34,504
|
Nice sig darksoul, lol.
WG
__________________
I play with Google. |
|
|
|
|
|
#14 |
|
So Fucking What
Industry Role:
Join Date: Jul 2006
Posts: 17,189
|
windowz ?
edit ...
__________________
best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself |
|
|
|
|
|
#15 |
|
Confirmed User
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
|
try this query instead, should be WAY faster... only hits MySQL once with a large insert
(note: that last substr just removes the trailing "," from the query so its valid) Code:
$dbcnx = mysql_connect('localhost','xxxxx', 'xxxxx');
mysql_select_db("testtable", $dbcnx);
$query = "";
for ($i = 10000; $i <= 20000; $i++) {
$query = $query . "('" . $i . "'),";
}
$query = "insert into users (muser) values " . substr($query, 0, strlen($query) - 1);
mysql_query($query);
__________________
112.020.756 |
|
|
|
|
|
#16 | |
|
Confirmed User
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
|
Quote:
__________________
112.020.756 |
|
|
|
|
|
|
#18 |
|
Confirmed User
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
|
the thing is i will be doing many many single inserts, so i set it to do one at a time on purpose
the problem was the table structure INNODB is 7-8x faster than InnoDB (at least on windows anyway)
__________________
ICQ: 298-523-037 |
|
|
|