MySQL vs SQL Server better performance???

11 views
Skip to first unread message

cghersi

unread,
Feb 9, 2011, 5:07:43 AM2/9/11
to SQL Server
Hi all,

I need to compare the performances of MySQL vs SQL Server 2008R2 in
case of huge INSERT into a table.

I've always been a fan of SQL Server, so I wanted to gear my boss
towards the use of SQL Server, but in this case I need to say the
MySQL is far bettere than SQL Server :-(

I prepared this test.
A simple table with bigint PK and a varchar(50) field.
SQL Server:
CREATE TABLE [dbo].[DataPoints](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[DataValue] [varchar](50) NULL,
CONSTRAINT [PK_DataPoints] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

MySQL:
CREATE TABLE `datapointswithpk` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`DataValue` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

A simple insert statement repeated 100.000 times:
SQL Server:
SET @start = GETDATE()
WHILE (@i < 100000)
BEGIN
SET @dataValue = N'mystuff'
INSERT INTO dbo.DataPoints (DataValue) VALUES (@dataValue)
SET @i = @i + 1
END
SET @end = GETDATE()
SELECT DATEDIFF(MS, @start, @end)

MySQL:
CREATE PROCEDURE addMassiveDataWithPK()
BEGIN
DECLARE i INT DEFAULT 1;
DECLARE rawVal VARCHAR(50);
WHILE i <= 100000 DO
SET rawVal = 'mystuff';
INSERT INTO datapointswithpk (DataValue) VALUES (rawVal);
SET i = i + 1;
END WHILE;
END$$

SET @start = now();
CALL addMassiveDataWithPK();
SET @end = now();
select (TIMESTAMPDIFF (MICROSECOND, @start, @end) / 1000) AS
millisecWithPK;

And now the results (average for 10 trials per platform):
SQL Server: 32434 millisec
MySQL: 4000 millisec (I think the best resolution for MySQL time is 1
second...)

Am I missing anything?
Why MySQL outperforms in this terrible way SQL Server?
I need to say that this has been a "sequential" test: perhaps
introducing some grade of parallelism may help SQL Server reaching
MySQL performances?

Please let me know!!

Bye
cghersi



Reply all
Reply to author
Forward
0 new messages