Yes, In-fact the data is expected to change once in week. 

Regarding Index on table, I know DAL doesn't provides a direct way of doing 
it, my question is once i have created an index on my table, do i need to 
modify anything in my controller?

-Sarbjit

On Thursday, May 22, 2014 7:54:54 PM UTC+5:30, Kiran Subbaraman wrote:
>
>  In addition to this, and assuming that the data doesn't change 
> frequently (days vs minutes), maybe a select-cache, with TTL of 24 hours 
> would help?
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Caching-selects
>
> ________________________________________
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Thu, 22-05-2014 7:39 PM, Anthony wrote:
>  
> First, you can simplify your function as follows:
>
>  def getResults():
>     tab2results = db(db.Table2.Release == request.vars.release_name).
> select(
>                      db.Table2.id, db.Table2.Year, orderby=~db.Table2.id)
>     return SELECT([OPTION(r.Year, _value=r.id) for r in tab2results],
>                   _name='table2_name')
>  
> I assume request.vars.release_name is actually the db.Table1 id field 
> value, not a string name, correct (otherwise, the query won't work)?
>
> In the above, insert "return BEAUTIFY(db._timings)" before the final 
> return, and call the function directly in a browser tab, with 
> release_name=[some id] in the query string. See how long the above query is 
> taking in that case. If the query itself is taking several seconds, try 
> creating an index on the "Release" field.
>
> Anthony
>
> On Thursday, May 22, 2014 9:38:56 AM UTC-4, Sarbjit wrote: 
>>
>>  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.Year.requires = IS_IN_DB(db,db.Table2.id,'%(Year)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+un...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
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.

Reply via email to