0

I upgraded my web2py from 2.3.2 to 2.14.6. Then made all required changes like updating/replacing web2py.js, jquery.js,web2py_ajax.html, appadmin.py, appadmin.html. Then made few css changes to match old UI. Did no changes in backend code.

Now when I visit application page containing web2py grid (SQLFORM.grid()) on web2py 2.14.6, it takes 34.775 seconds and on version 2.3.2 same page with same number of records it takes 0.686 seconds. Grid has around 4600 records. Pages that doesn't have grid, took approx same time to load on both versions.

I did time profiling and found that gluon/html.py is taking most of the time.

Time profiling results

2.3.2 : https://paste.ubuntu.com/23602259/

2.14.6 : https://paste.ubuntu.com/23602261/

Also I added print statement before and after grid definition, It took 18 seconds on 2.14.6 and 10 miliseconds on 2.3.2.

SQLFORM.grid() definition is similar to following:

grid = SQLFORM.grid(query,
        create=True,
        csv=False, deletable=False, searchable=search_query,
        showbuttontext=False, links=links, links_placement='left',
        maxtextlengths=textlengths, upload=URL('download'),
        fields=[db.notice.UIN, db.notice.classname, db.notice.title,
                db.notice.type,
                db.notice.description,
                db.notice.due_date, db.notice.status,
                db.notice.risk, db.notice.consequence,
                db.notice.document,
                db.notice.other])

sample query in above grid-

((((user_notice.notice = notice.id) AND (user_notice.auth_user = 19)) AND
  (notice.status IN ('Closed','Open','New'))) AND
 (notice.due_date IS NOT NULL))

I tested this on my local computer- Ubuntu 14.04,Python 2.7.6 and mysql db.

Why newer version takes more time to load grid? Is there any changes required in application code after upgrade?

Please help me to solve this issue.

Thank you

Gaurav Vichare
  • 1,143
  • 2
  • 11
  • 26
  • How did you upgrade? Did you get the updated DAL, which is now in a separate repository? This kind of issue might be better handled on the Google Group. – Anthony Dec 09 '16 at 19:15
  • yes, I posted this in google group. I downloaded web2py from web2py.com and installed app on new web2py using admin panel, after cleaning cache/sessions and creating w2p package. – Gaurav Vichare Dec 10 '16 at 05:08
  • @GauravVichare did you solve this? Would you share your knowledge? – Eggcellentos Jan 10 '19 at 09:25
  • 1
    @ghosh as far as I remember, I break join query which is passed to SQLFORM.grid(). I calculated ids separately and passed belongs() query to SQLFORM.grid(). `usr_notic = db(db.user_notice.auth_user == 19).select(db.user_notice.notic)` `user_notic_list = [t['notic'] for t in usr_notic]` `query = db.notice.id.belongs(user_notic_list) & ....` – Gaurav Vichare Jan 11 '19 at 08:57

0 Answers0