* 4 DB Nodes cluster
* 1 Mysqld

CREATE DATABASE Bar;
USE Bar;

CREATE TABLE Foo (A INTEGER, B INTEGER, C INTEGER) Type=NDB;

INSERT INTO TABLE Foo VALUES (0,0,0);
INSERT INTO TABLE Foo VALUES (1,0,0);
INSERT INTO TABLE Foo VALUES (2,0,0);
INSERT INTO TABLE Foo VALUES (3,0,0);
INSERT INTO TABLE Foo VALUES (4,0,0);
INSERT INTO TABLE Foo VALUES (5,0,0);
INSERT INTO TABLE Foo VALUES (6,0,0);
INSERT INTO TABLE Foo VALUES (7,0,0);
INSERT INTO TABLE Foo VALUES (8,0,0);
INSERT INTO TABLE Foo VALUES (9,0,0);

* Perl script to run on two machines.

#!/usr/bin/perl
#
# @(#)$Id$
#

use DBI;
use Time::HiRes qw (gettimeofday);

$ClientId = $ARGV[0];
$perfmod = $ARGV[1];

if (!defined $ClientId) {
    print "ClientId is a required parameter.\n";
    exit 1;
}

if ($perfmod <= 0) {
    $perfmod = 100;
}

$dbdsn = "dbi:mysql:database=cluster;host=10.154.99.201;port=3307";
$dbuser = "root";
$dbpassword = "";

my $dbh = DBI->connect ($dbdsn,
			$dbuser,
			$dbpassword,{RaiseError => 0,
				     PrintError => 1,
				     AutoCommit => 0});

$checkpoint = 0;
$updates = 0;

while (1) {

    #
    # Get timestamp for performance computations   
    #

    if ($checkpoint == 0) {
	($sec, $usec) = gettimeofday();
	
	$checkpoint = $sec * 1000 + int($usec / 1000);
    }

    
    $ts = time % 10;

    $sth = $dbh->prepare ("UPDATE Foo SET B=?,C=C+1 WHERE A=?");
    $status = $sth->execute ($ClientId, $ts);
    $updates++;

    if ($updates % $perfmod == 0) {
	($sec, $usec) = gettimeofday();
	
	$checkpoint = ($sec * 1000 + int($usec / 1000)) - $checkpoint;

	print "================================================================\n";
	print "$updates UPDATEs in $checkpoint ms   " . (1000 * $updates) / $checkpoint . " req/s\n";
	print "================================================================\n";

	$checkpoint = 0;
	$updates = 0;
    }

    $dbh->commit();
}

* Performance with one script running is ~ 350 req/s

* Performance with two scripts running is ~ 50 req/s

* Add PRIMARY KEY on table Foo

ALTER TABLE Foo ADD PRIMARY KEY(A);

* Performance with one script running is ~ 500 req/s

* Running two scripts leads to the following error:

DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction at foo.pl line 66.
DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction at foo.pl line 66.

