It looks like iterating over the db result object is what's causing
the slowdown.

With a small result set (20 records), here are the times in 0.31 to do
the db query and to render xml by iterating over the result object:
    db: 0.01993 second
    render: 0.00087 second
    total: 0.02671 second

Then with a large result set (17,142 records):
    db: 0.09306 second
    render: 67.98967 seconds
    total: 68.08277

On version 0.23 and the large result set (17,142 records):
    db: 0.06552
    render: 0.16659
    total: 0.23248

Clearly the render function is the problem.  This function takes the
db result object as a parameter, and iterates over it to create the
xml:

    def render_xml(items):
        xml = '<?xml version=\"1.0\"?>\n'
        xml += '<rootnode>\n'
        for item in items:
            xml += '<itemnumber>%s</itemnumber>\n' % item.id
            xml += '<description>%s</description>\n' % item.descr
            xml += '<quantity>%s</quantity>\n' % item.qty
            ...
        return xml

    dbresult = db.query(querystring)
    return render_xml(dbresult)

On Jan 1, 8:04 pm, "Aaron Swartz" <[email protected]> wrote:
> Can you share more details? Code? Profiler output?
>
> On Jan 1, 2009 10:55 PM, "mb" <[email protected]> wrote:
>
> I have a web service that queries a database and returns a fairly
> large xml document based on parameters in the URL.
>
> This morning, with web.py 0.23, it would return a 17,142 line response
> (491k) in 200 ms.
>
> This afternoon I upgraded to 0.31, and it now takes 56 seconds for the
> same action.
>
> For the entire 56 seconds, the cpu is pegged at 100% on the python
> process with just one request, where on 0.23 I could run many
> simultaneous requests and the cpu was rarely over 40%.
>
> Any ideas why my performance has dropped by a factor of 300?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to