Performance Problems when selecting HUGE amounts of data from MySQL dbs

Skip Montanaro skip at pobox.com
Wed Jan 9 16:45:45 CET 2002


    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)

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list