read call without fields list takes long time

Asked by SG E-ndicus(Selvam)

Hi all,

I was using xmlrpc calls to read res.partner fields

data = sock.execute(dbname, uid, pwd, 'res.partner', 'read',range(50),LIST_OF_10_FIELDS)

When I passed some 10 fields,
It took some 0.017311000824 seconds on an average to return the result.

When I passed,
data = sock.execute(dbname, uid, pwd, 'res.partner', 'read',range(50),[])
It took 0.34 seconds on an average. ( around 20x slower )

The read and _read_flat gets called repeatedly (orm.py) when no input fields are passed thus taking a lot of time.

I would like to know, If this is a bug or expected one.

Note:
  I am using python's timeit module to figure out timings.

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
xrg
Solved:
Last query:
Last reply:
Revision history for this message
Best xrg (xrg) said :
#1

On Monday 23 May 2011, you wrote:
> New question #158641 on OpenERP Server:
> https://answers.launchpad.net/openobject-server/+question/158641
>
>
> Hi all,
>
> I was using xmlrpc calls to read res.partner fields
>
> data = sock.execute(dbname, uid, pwd, 'res.partner',
> 'read',range(50),LIST_OF_10_FIELDS)
>
> When I passed some 10 fields,
> It took some 0.017311000824 seconds on an average to return the result.
>
> When I passed,
> data = sock.execute(dbname, uid, pwd, 'res.partner', 'read',range(50),[])
> It took 0.34 seconds on an average. ( around 20x slower )
>
> The read and _read_flat gets called repeatedly (orm.py) when no input
> fields are passed thus taking a lot of time.

It is expected behavior of the ORM. What you see under the hood, is the
res.partner object performing multiple _read_flat() calls because of its
function fields. Calling read([ids], []) will try to fetch all these computed
fields from a model (res.partner is the champion) overloaded with fields.
For every of those function fields, a _read_flat() will be triggered (note, this
equals the number of columns, not number of fetched records, aka. lines)

In an experiment, I have written the "function_fields_browse" feature, which
tries to reuse the browse cache and data from the parent _read_flat() call, so
that function fields don't need to query the database again:
http://git.hellug.gr/?p=xrg/openobject-server;a=commitdiff;h=eb228f22c83d8f8d9

Still, I wouldn't expect to stay in the 17ms range, since the computation of
fields will take some time.

Revision history for this message
SG E-ndicus(Selvam) (e-ndicus) said :
#2

Thanks xrg, that solved my question.