Re: PostgreSQL as a local in-memory cache

From: Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
To: Pierre C <lists(at)peufeu(dot)com>
Cc: Greg Smith <greg(at)2ndquadrant(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL as a local in-memory cache
Date: 2010-06-16 19:17:11
Message-ID: AANLkTikFERJoyWCOBuf5ECvHhxiSCQZPFlBNfP-zkPMd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, Jun 16, 2010 at 4:22 AM, Pierre C <lists(at)peufeu(dot)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(at)jonathangardner(dot)net

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jonathan Gardner 2010-06-16 19:19:20 Re: PostgreSQL as a local in-memory cache
Previous Message Jonathan Gardner 2010-06-16 19:11:27 Re: PostgreSQL as a local in-memory cache