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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-18-2007, 02:42 AM   #1
Myst
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
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 02:47 AM   #2
spasmo
Confirmed User
 
Join Date: Dec 2005
Location: Couch
Posts: 2,678
You have to think spindles. What is your disk IO while doing this?
__________________

Surfers: Go here for hot babes.
spasmo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 02:56 AM   #3
Myst
Confirmed User
 
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
about 400KB while its inserting
the cpu mysql uses is around 30&#37; during the inserts..

__________________
ICQ: 298-523-037
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:00 AM   #4
spasmo
Confirmed User
 
Join Date: Dec 2005
Location: Couch
Posts: 2,678
I'm a bit stymied on this one. It usually points to disk IO.

Anyone else with ideas out there? I must be missing something obvious.
__________________

Surfers: Go here for hot babes.
spasmo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:02 AM   #5
Myst
Confirmed User
 
Join Date: Feb 2004
Location: Alberta, Canada
Posts: 4,708
is it normally much faster?
__________________
ICQ: 298-523-037
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:06 AM   #6
WiredGuy
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.
WiredGuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:12 AM   #7
Myst
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&#37; slower using the same code..
__________________
ICQ: 298-523-037
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:18 AM   #8
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by WiredGuy View Post
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
thats php
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:21 AM   #9
WiredGuy
Pounding Googlebot
 
Industry Role:
Join Date: Aug 2002
Location: Canada
Posts: 34,504
Quote:
Originally Posted by darksoul View Post
thats php
Perl too. Maybe its Windows that really makes it all slow
WG
__________________
I play with Google.
WiredGuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:21 AM   #10
darksoul
Confirmed User
 
darksoul's Avatar
 
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);
should be blazing fast.
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:22 AM   #11
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by WiredGuy View Post
Perl too. Maybe its Windows that really makes it all slow
WG
I meant the code he posted is php
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:25 AM   #12
Myst
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

Last edited by Myst; 02-18-2007 at 03:27 AM..
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:31 AM   #13
WiredGuy
Pounding Googlebot
 
Industry Role:
Join Date: Aug 2002
Location: Canada
Posts: 34,504
Nice sig darksoul, lol.
WG
__________________
I play with Google.
WiredGuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:33 AM   #14
2012
So Fucking What
 
2012's Avatar
 
Industry Role:
Join Date: Jul 2006
Posts: 17,189
windowz ?

edit ...
__________________
best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

Last edited by 2012; 02-18-2007 at 03:33 AM.. Reason: i like big tits
2012 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:37 AM   #15
tical
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);
i think thats right, but you get the idea... you can do multiple inserts in one query w/ MySQL so handle the processing beforehand and eliminate all the redundant connections, etc.
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:38 AM   #16
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
Quote:
Originally Posted by darksoul View Post
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);
should be blazing fast.
blah crap i didnt even see this haha... ah well
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 03:39 AM   #17
rotterdammer
Confirmed User
 
Join Date: Feb 2006
Posts: 1,523
Bump for you lol
rotterdammer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2007, 05:47 AM   #18
Myst
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
Myst is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.