Re: PostgreSQL as a local in-memory cache
| От | Jonathan Gardner |
|---|---|
| Тема | Re: PostgreSQL as a local in-memory cache |
| Дата | |
| Msg-id | AANLkTikFERJoyWCOBuf5ECvHhxiSCQZPFlBNfP-zkPMd@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: PostgreSQL as a local in-memory cache ("Pierre C" <lists@peufeu.com>) |
| Ответы |
Re: PostgreSQL as a local in-memory cache
|
| Список | 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 по дате отправления: