Re: PostgreSQL as a local in-memory cache - Mailing list pgsql-performance

From Jonathan Gardner
Subject Re: PostgreSQL as a local in-memory cache
Date
Msg-id AANLkTikFERJoyWCOBuf5ECvHhxiSCQZPFlBNfP-zkPMd@mail.gmail.com
Whole thread Raw
In response to Re: PostgreSQL as a local in-memory cache  ("Pierre C" <lists@peufeu.com>)
Responses Re: PostgreSQL as a local in-memory cache
List pgsql-performance
On Wed, Jun 16, 2010 at 4:22 AM, Pierre C <lists@peufeu.com> wrote:
>
> import psycopg2
> from time import time
> conn = psycopg2.connect(database='peufeu')
> cursor = conn.cursor()
> cursor.execute("CREATE TEMPORARY TABLE test (data int not null)")
> conn.commit()
> cursor.execute("PREPARE ins AS INSERT INTO test VALUES ($1)")
> cursor.execute("PREPARE sel AS SELECT 1")
> conn.commit()
> start = time()
> tx = 0
> N = 100
> d = 0
> while d < 10:
>        for n in xrange( N ):
>                cursor.execute("EXECUTE ins(%s)", (tx,));
>                #~ conn.commit()
>                #~ cursor.execute("EXECUTE sel" );
>        conn.commit()
>        d = time() - start
>        tx += N
> print "result : %d tps" % (tx / d)
> cursor.execute("DROP TABLE test");
> conn.commit();
>

I'm not surprised that Python add is so slow, but I am surprised that
I didn't remember it was... ;-)

--
Jonathan Gardner
jgardner@jonathangardner.net

pgsql-performance by date:

Previous
From: Jonathan Gardner
Date:
Subject: Re: PostgreSQL as a local in-memory cache
Next
From: Jonathan Gardner
Date:
Subject: Re: PostgreSQL as a local in-memory cache