Below is the snippets from code (I have changed few field names as I can't share the exact field names)
--> Data base db.define_table('Table1', Field('Release'), format='%(Release)s') db.define_table('Table2', Field('Release',db.Table1), Field('Year'), format='%(Year)s') db.define_table('Table3', Field('Manfucturer',writable=False), Field('MID'), Field('Year',db.Table2,writable=False), Field('Engineer'), Field('Location',writable=False), Field('Title',writable=False), Field('Description','text'), Field('City',writable=False)) db.Table2.Release.requires = IS_IN_DB(db,db.Table1.id,'%(Release)s') db.Table3.MID.requires = IS_IN_DB(db,db.Table2.id,'%(MID)s') --> This function is called by AJAX on change of first option in drop down def getResults(): tab2results = db(db.Table2.Release==request.vars.release_name).select(orderby=~db.Table2.id) result = "<select name='table2_name'>" for tab2 in tab2results: print tab2 result += "<option value='" + str(tab2.id) + "'>" + tab2.Year + "</option>" result += "</select>" return XML(result) No, I don't have an index for the table. On Thursday, May 22, 2014 6:50:02 PM UTC+5:30, Anthony wrote: > > Would still help to see your specific model code. Is the field in question > a reference field with a "represent" attribute? If so, you'll get separate > queries for each item in order to lookup the represent value. How many > records in the table? Do you have an index on the field being searched? If > you execute the same query in a separate DB client, how long does it take? > > Anthony > > On Thursday, May 22, 2014 8:37:55 AM UTC-4, Sarbjit wrote: >> >> Hi Anthony, >> >> Code is almost identical to the code posted in slice with change in field >> names and number of records. Only additonal difference is that I am using >> "orderby" in the query before returing the results. >> >> Surprisingly, sometime the result appears fast (within 2-3 seconds) but >> some time it takes long time to populate it. >> >> -Sarbjit >> >> On Thursday, May 22, 2014 4:46:55 PM UTC+5:30, Anthony wrote: >>> >>> Would help to see some code. 4-5 seconds sounds much too long. >>> >>> You might also look into >>> http://dev.s-cubism.com/plugin_lazy_options_widget. >>> >>> Anthony >>> >>> On Thursday, May 22, 2014 12:17:42 AM UTC-4, Sarbjit wrote: >>>> >>>> Hi, >>>> >>>> I am using cascading drop-down based on the slice posted on " >>>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2". >>>> >>>> In my application, the number of sub-records for drop-down are typically >>>> in >>>> range of 50-60, so every-time I change the first option in drop down, it >>>> takes significant time (around 4-5 seconds) to populate my second drop >>>> down. >>>> >>>> I was wondering if there is a way to make this fast by means of caching >>>> or by storing the data for all the records the first time when user logs >>>> into the system and then using that data. Can some one please comment on >>>> how to address this problem and if possible, an example would be helpful. >>>> >>>> -Sarbjit >>>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.