Apologies for the unfinished message.  The Gmail interface in the browser
and I am not really friends.

The problem with the abovementioned query is that it adds a lot of load to
the server as there are 130+ million records in the rresearch table and
about as much in the isi_alt_names table making the query very slow.
Without the 'rresearch.id' in the orderby-section the query runs for about
200 ms and with it the sorting and merging of the sort results of the two
tables takes about 7 minutes.

How can I prevent web2py from adding the additional orderby field?

Regards.
Johann



On 28 May 2015 at 12:28, Johann Spies <johann.sp...@gmail.com> wrote:

> The following code:
>
> query = ((db.rresearch.id == db.isi_alt_names.rsc_id)&
>                   (db.rresearch.nu.upper().like(request.vars.country +
> '%')))
>
> data = SQLFORM.grid(query, searchable = False, links = links, fields =
> fields,
>                          editable = False, deletable = False, details =
> False,
>                          maxtextlength = 60,
>                          create = False,
>                          cache_count = count,
>                          orderby = ~db.isi_alt_names.code)
>
> produces the following query:
>
> SELECT  rresearch.nf, rresearch.nu, isi_alt_names.code,
> isi_alt_names.institution, isi_alt_names.id, rresearch.id FROM rresearch, 
> isi_alt_names WHERE (rresearch.id = isi_alt_names.rsc_id) ORDER BY 
> isi_alt_names.code DESC, rresearch.id LIMIT 20 OFFSET 0;
>
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

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