473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Concurrent testing PostgreSQL Vs MySQL

Hi All,

I tested "concurrent testing" in MySQL. It works fine. But I couldn't do in PostgreSQL 7.3.4 on HPUX IPF. I got deadlock problem. I used the PHP script to update table( one script increment the column & another one decrement the column). Is the postgres support the concurrent access to update database?

I got the following errors:

test=# ERROR: deadlock detected
ERROR: deadlock detected
ERROR: deadlock detected
.....
Regs,
Durai.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003
Nov 12 '05 #1
11 5415
Durai wrote:
Hi All,

I tested "concurrent testing" in MySQL. It works fine. But I
couldn't do in PostgreSQL 7.3.4 on HPUX IPF. I got deadlock problem. I
used the PHP script to update table( one script increment the column &
another one decrement the column). Is the postgres support the
concurrent access to update database?

I got the following errors:

test=# ERROR: deadlock detected
ERROR: deadlock detected
ERROR: deadlock detected


Did you commited the transaction anywhere? Can we see the php code?

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2
Hello Shridhar,

The script content is:

# cat testpgsql.php

<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
pg_close($dbconn);
?>
#
The test result is:

# ab -c 5 -n 50 http://127.0.0.1:7070/testpgsql.php

This is ApacheBench, Version 1.3d <$Revision: 1.67 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).....done
Server Software: Apache/1.3.27
Server Hostname: 127.0.0.1
Server Port: 7070

Document Path: /testpgsql.php
Document Length: 0 bytes

Concurrency Level: 5
Time taken for tests: 51.508 seconds
Complete requests: 50
Failed requests: 34
(Connect: 0, Length: 34, Exceptions: 0)
Broken pipe errors: 0
Total transferred: 15000 bytes
HTML transferred: 6750 bytes
Requests per second: 0.97 [#/sec] (mean)
Time per request: 5150.80 [ms] (mean)
Time per request: 1030.16 [ms] (mean, across all concurrent requests)
Transfer rate: 0.29 [Kbytes/sec] received

Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 443 4973 3067.8 4513 12357
Waiting: 441 4973 3067.9 4513 12357
Total: 443 4973 3067.7 4513 12357

Percentage of the requests served within a certain time (ms)
50% 4513
66% 6278
75% 7308
80% 7712
90% 9422
95% 10723
98% 12357
99% 12357
100% 12357 (last request)
#
----- Original Message -----
From: "Shridhar Daithankar" <sh*****************@myrealbox.com>
To: "Durai" <vi**************@lycos.co.uk>
Cc: <pg***********@postgresql.org>
Sent: Friday, November 21, 2003 3:33 PM
Subject: Re: [GENERAL] Concurrent testing PostgreSQL Vs MySQL

Durai wrote:
Hi All,

I tested "concurrent testing" in MySQL. It works fine. But I
couldn't do in PostgreSQL 7.3.4 on HPUX IPF. I got deadlock problem. I
used the PHP script to update table( one script increment the column &
another one decrement the column). Is the postgres support the
concurrent access to update database?

I got the following errors:

test=# ERROR: deadlock detected
ERROR: deadlock detected
ERROR: deadlock detected


Did you commited the transaction anywhere? Can we see the php code?

Shridhar


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003
Nov 12 '05 #3
Użytkownik Durai napisał:
Hello Shridhar,

The script content is:
** *# cat te**stpgsql.php*
*
*<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test user=postgres"); $result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
pg_close($dbconn);

You have to read about transactions in PostgreSQL or you should turn on
autocommit in conf file...

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #4
Durai wrote:
Hello Shridhar,

The script content is:
**
*# cat te**stpgsql.php*
*
*<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
$result = pg_exec ($dbconn, "commit;");
pg_close($dbconn);
?>
#


Try it now. It should work without problem.

shridhar
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #5
Hello Sridhar,

No. Still Its not working.

I used the following command.

# bin/ab -c 5 -n 50 http://127.0.0.1:7070/testpgsql.php

I got the following error:

test=# ERROR: deadlock detected
ERROR: deadlock detected
WARNING: COMMIT: no transaction in progress
WARNING: COMMIT: no transaction in progress
WARNING: COMMIT: no transaction in progress
WARNING: COMMIT: no transaction in progress
WARNING: COMMIT: no transaction in progress
WARNING: COMMIT: no transaction in progress
ERROR: deadlock detected
ERROR: deadlock detected

The script works only it has to be like:

<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
pg_close($dbconn);
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
pg_close($dbconn);
?>

Regs,
Durai.
----- Original Message -----
From: "Shridhar Daithankar" <sh*****************@myrealbox.com>
To: "Durai" <vi**************@lycos.co.uk>
Cc: <pg***********@postgresql.org>
Sent: Friday, November 21, 2003 4:09 PM
Subject: Re: [GENERAL] Concurrent testing PostgreSQL Vs MySQL

Durai wrote:
Hello Shridhar,

The script content is:
**
*# cat te**stpgsql.php*
*
*<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");


$result = pg_exec ($dbconn, "commit;");
pg_close($dbconn);
?>
#


Try it now. It should work without problem.

shridhar
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #6
Damn.. I forgot to begin the transaction..

Shridhar Daithankar wrote:
Durai wrote:
Hello Shridhar,
The script content is:
** *# cat te**stpgsql.php*
*
*<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "begin;");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");

$result = pg_exec ($dbconn, "commit;");
pg_close($dbconn);
?>
#


Check this..

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #7
Hello Sridhar,

Now, It works. Thanks lot.

But Still I have doubt:

1. How MySQL works in this case? It has any default "autocommit"?

2. Is there any other method to test for "concurrent testing"?

Regs,
Durai.
----- Original Message -----
From: "Shridhar Daithankar" <sh*****************@myrealbox.com>
To: "Shridhar Daithankar" <sh*****************@myrealbox.com>
Cc: "Durai" <vi**************@lycos.co.uk>; <pg***********@postgresql.org>
Sent: Friday, November 21, 2003 5:28 PM
Subject: Re: [GENERAL] Concurrent testing PostgreSQL Vs MySQL

Damn.. I forgot to begin the transaction..

Shridhar Daithankar wrote:
Durai wrote:
Hello Shridhar,
The script content is:
** *# cat te**stpgsql.php*
*
*<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
user=postgres");
$result = pg_exec ($dbconn, "begin;");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");

$result = pg_exec ($dbconn, "commit;");
pg_close($dbconn);
?>
#


Check this..

Shridhar

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #8
Durai wrote:
Hello Sridhar,

Now, It works. Thanks lot.

But Still I have doubt:

1. How MySQL works in this case? It has any default "autocommit"?
Depends. What version of mysql you are using? If you are using mysql 3.x and/or
non-innodb tables, you don't have transactions in first place. Mysql does not
need autocommit in earlier version because it does not have transactions in
first place.
2. Is there any other method to test for "concurrent testing"?


Against mysql? I doubt. You can try scaling number of concurrent connections and
number of rows in database. Furthermore don't do bulk update but do selective
random updates. And verify the results in your php section.
Shridhar
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #9
On Fri, Nov 21, 2003 at 03:39:42PM +0530, Durai wrote:
The script content is:

# cat testpgsql.php

<?php
$dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test user=postgres");
$result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
$result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
pg_close($dbconn);
?>


Is this the exact equivalent test of the MySQL "concurrent" test?
(Ignoring the transaction handling difference)

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"La tristeza es un muro entre dos jardines" (Khalil Gibran)

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #10
"Durai" <vi**************@lycos.co.uk> writes:
# cat testpgsql.php <?php
$dbconn =3D pg_connect("host=3D172.16.1.158 port=3D5432 dbname=3Dtest user=
=3Dpostgres");
$result =3D pg_exec ($dbconn, "update table2 set C2=3DC2+1;");
$result =3D pg_exec ($dbconn, "update table2 set C2=3DC2-1;");
pg_close($dbconn);
?>
#


It doesn't surprise me that concurrent execution of that script would
yield deadlocks in Postgres but not in MySQL. The reason is that there
*isn't* any concurrent execution of that script going on in MySQL.
Each UPDATE command will (if I understand their behavior correctly) take
a table-level lock until it's done, thereby preventing any other UPDATE
from proceeding concurrently. Postgres tries to do the locking at the
row level, and so can easily get into a state where transaction A has
updated row 1 and now wants to update row 2, whereas transaction B has
updated row 2 and now wants to update row 1 ... ie, deadlock.

You could "fix" this by taking a table-level lock ("LOCK TABLE table2")
before starting the updates, thereby dumbing Postgres down to MySQL's
level. I don't see the point though, as this benchmark is completely
irrelevant to most real-world uses. In the real world you more commonly
have different transactions independently updating different rows of a
table. In that sort of scenario, MySQL loses badly because it cannot
process such updates concurrently, due to table-level locking. Unless
your real application mostly does whole-table updates, you should
rewrite your benchmark to be more representative of what you really need
to do.

BTW, I think that when you use InnoDB tables, MySQL does use row-level
locks for updates, and so would likely show the same deadlock risk as
Postgres.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #11
Durai wrote:
Hello Sridhar,

Now, It works. Thanks lot.

But Still I have doubt:

1. How MySQL works in this case? It has any default "autocommit"?
I am more worried what this test is testing at all and what MySQL
finally returns as a supposed to be correct result.

In particular, does the row after that test was running for some time
report the correct value? Looking at the test it should be the same
value the test started from.

Also, just as a side note, this sort of isolated, single table, single
row, as primitive a query as possible tests is usually the stuff where
MySQL beats PostgreSQL, so I wouldn't be surprised if one more "from
another world" test shows MySQL's strength over PostgreSQL.
Jan

2. Is there any other method to test for "concurrent testing"?

Regs,
Durai.
----- Original Message -----
From: "Shridhar Daithankar" <sh*****************@myrealbox.com>
To: "Shridhar Daithankar" <sh*****************@myrealbox.com>
Cc: "Durai" <vi**************@lycos.co.uk>; <pg***********@postgresql.org>
Sent: Friday, November 21, 2003 5:28 PM
Subject: Re: [GENERAL] Concurrent testing PostgreSQL Vs MySQL

Damn.. I forgot to begin the transaction..

Shridhar Daithankar wrote:
> Durai wrote:
>> Hello Shridhar,
>> The script content is:
>> ** *# cat te**stpgsql.php*
>> *
>> *<?php
>> $dbconn = pg_connect("host=172.16.1.158 port=5432 dbname=test
>> user=postgres");


$result = pg_exec ($dbconn, "begin;");
>> $result = pg_exec ($dbconn, "update table2 set C2=C2+1;");
>> $result = pg_exec ($dbconn, "update table2 set C2=C2-1;");
> $result = pg_exec ($dbconn, "commit;");
>> pg_close($dbconn);
>> ?>
>> #


Check this..

Shridhar

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = Ja******@Yahoo.com #
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: waasserr | last post by:
why mysql is more diffused than postgresql? Postgresql licence is really free more than mysql, but why postgresql is not much diffusing? the future will be of mysql?
0
by: Marek Lewczuk | last post by:
Hello group, For everyone who thinks about moving from MySQL to PostgreSQL I have a realy bad news - It's not worth. Why, You may ask... A few days ago I have installed and tested PostgreSQL,...
33
by: Joshua D. Drake | last post by:
Hello, I think the below just about says it all: http://www.commandprompt.com/images/mammoth_versus_dolphin_500.jpg Sincerely, Joshua Drake
20
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
11
by: Errol Neal | last post by:
Hi all, Not sure if this is a question for a php list or this one, but I'll give it a shot and if I am wrong, please do not crucify me. :-) There is a php based sourceforge project called...
26
by: jini us | last post by:
Hi, I am starting a new project where I intend to use embedded database server in my win32 application. I intend to use VC++ microsoft studio 6.0 as my development environment. The...
3
by: Marek Lewczuk | last post by:
Hello, I have changed DB from MySQL to PostgreSQL. When I have run my application on PostgreSQL it was disaster - it was much slower than MySQL... I have tried to change PG configuration file...
4
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light,...
1
by: Richard Huxton | last post by:
On Thursday 12 February 2004 20:25, Prashanthi Muthyala wrote: > Hi Richard Hi Prashanthi - nice to hear from you again. I've taken the liberty of cc-ing the general list on this, since there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.