Grid search collects all records from all fields on each request. Isn't this bad for performance?

31 views
Skip to first unread message

jcrm...@gmail.com

unread,
Apr 29, 2019, 6:22:26 PM4/29/19
to web...@googlegroups.com
Grid search collects all records from all fields on each request. Isn't this bad for performance?

Isn't it possible to change this behavior to only load the records when the user selects a specific field to do the search?

web2py 2.18.5
Python 3.7.1 x86
Firefox 66.0.3 x64
Windows 7 Pro x64 SP1+all upds

Anthony

unread,
Apr 29, 2019, 7:34:10 PM4/29/19
to web2py-users
On Monday, April 29, 2019 at 6:22:26 PM UTC-4, jcrm...@gmail.com wrote:
Grid search collects all records from all fields on each request. Isn't this bad for performance?

Are you referring to "reference" fields, which result in a select element showing associated values from the foreign table? If so, that is the result of the default IS_IN_DB validator given to such fields, which results in a select element being created when the field appears in forms as well as the search menu. You can override this behavior by putting the validator in a list:

db.mytable.myreferencefield.requires = [db.mytable.myreferencefield]

However, in that case, forms and the search menu will simply present a numeric input field, and you would need to search by the record ID, so probably not very useful. Alternatively, you can specify an autocomplete widget, but that won't help in the grid search menu.
 
Isn't it possible to change this behavior to only load the records when the user selects a specific field to do the search?

Feel free to submit a pull request. Alternatively, you can specify both a custom search menu and a custom search function via the "search_widget" and "searchable" arguments, respectively. For ideas on the former, see SQLFORM.search_menu, and for the latter, see SQLFORM.build_query.

Anthony

jcrm...@gmail.com

unread,
Apr 30, 2019, 4:40:24 AM4/30/19
to web2py-users
Ok, thanks Anthony.
Reply all
Reply to author
Forward
0 new messages