MySQLdb

Batista, Facundo FBatista at uniFON.com.ar
Tue Jan 25 16:12:22 EST 2005


[Daniel Bowett]

#- The problem I have is that it takes just over two minuted to 
#- execute the 
#- 3000 insert statements which seems really slow! I am running it on a 
#- machine with a 1.5 Ghz Pentium M Processor and Gig Of Ram. I 
#- dont think 
#- the machine is to blame for the speed because during execution the 
#- processor sits at about 10% and there is loads of free RAM.
#- 
#- Does anyone know if this sort of speed sounds right?

Well, I made the following code.

mod_mysql is mine, but is just a wrapper around the standard module. Here I
only use the .accion() method of the Consulta object, that let me send an
action (query, insert, etc) to the database.

So I generate a temporary table of four fields, and prepared a list of 3000
entries, each one is a tuple of four elements: ten characters choosed
randomly.

---

import random, string, time
import mod_mysql

bdd = mod_mysql.Consulta("pytonisa", "fbatista", "password", "otainfo")

bdd.accion("create temporary table tmp.prueba (c1 char(10), c2 char(10), c3
char(10), c4 char(10));")

r = random.Random()
let = string.letters + string.digits
fuente = [tuple([''.join(r.sample(let, 10)) for j in range(4)]) for x in
range(3000)]

t = time.time()
for reg in fuente:
    bdd.accion('insert into tmp.prueba values ("%s", "%s", "%s", "%s");' %
tuple(reg))
print time.time() - t

---

I only measure the time of the inserts. It took 0.269818067551 seconds.

I'm using a Pentium 4 2.8 GHz, 256 MB of RAM, with Fedora Core 2, kernel
2.4.22, python 2.3.3 (GCC 3.3.2), and MySQL 4.0.18.

Regards,

.    Facundo

Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/


  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
ADVERTENCIA.

La información contenida en este mensaje y cualquier archivo anexo al mismo,
son para uso exclusivo del destinatario y pueden contener información
confidencial o propietaria, cuya divulgación es sancionada por la ley.
Si Ud. No es uno de los destinatarios consignados o la persona responsable
de hacer llegar este mensaje a los destinatarios consignados, no está
autorizado a divulgar, copiar, distribuir o retener información (o parte de
ella) contenida en este mensaje. Por favor notifíquenos respondiendo al
remitente, borre el mensaje original y borre las copias (impresas o grabadas
en cualquier medio magnético) que pueda haber realizado del mismo.
Todas las opiniones contenidas en este mail son propias del autor del
mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones
Personales S.A. o alguna empresa asociada.
Los mensajes electrónicos pueden ser alterados, motivo por el cual
Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación
cualquiera sea el resultante de este mensaje.
Muchas Gracias.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050125/5be102dc/attachment.html>


More information about the Python-list mailing list