Performance Problems when selecting HUGE amounts of data from MySQL dbs

Steve Holden sholden at holdenweb.com
Wed Jan 9 11:28:06 EST 2002


"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.1010591172.21624.python-list at python.org...
>
>     Gabriel> db.execute("SELECT myfield FROM table")
>     Gabriel> data=db.fetchall()
>     Gabriel> giantstring=""
>     Gabriel> for record in data:
>     Gabriel>     giantstring+=record
>
>     Gabriel> but this is way too slow.
>
> How about
>
>     db.execute("SELECT myfield FROM table")
>     data=db.fetchall()
>     giantstring=[]
>     for record in data:
>         giantstring.append(record)
>     giantstring = "".join(giantstring)
>
or
    db.execute("SELECT myfield FROM table")
    giantstring = "".join([itm[0] for itm in db.fetchall()])

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list