RE: [Modeling-users] Problem with modeling efficency
Status: Abandoned
Brought to you by:
sbigaret
|
From: <luk...@po...> - 2003-11-29 15:17:39
|
Hi
Thanks Sebastien for all advices. I use both optimization methods and there
are my results. They may be interesting. Given time is an average of 10
measurments
Fetching one table 'Mothers' with 100 records and three tables related with
it:
0. Fetching table in "pure" PostgreSQL by psql: 0.025 seconds
With Modeling:
1. Without any optimization: 14.20 seconds
2. Setting permanent DB connection: 1.31 seconds
3. Setting permanent DB connection and batchFetch 1.14 seconds
Now, its almost perfect
Code after optimization:
---------------------
# first optimization
import os
os.environ['MDL_PERMANENT_DB_CONNECTION']='1'
# second optimization
def databaseContext(entityName, ec):
from Modeling.FetchSpecification import FetchSpecification
fs=FetchSpecification(entityName)
return ec.rootObjectStore().objectStoreForFetchSpecification(fs)
EC=EditingContext()
mothers=EC.fetch('Mothers')
from Modeling.ModelSet import defaultModelSet
dbContext=databaseContext('Mothers', EC)
rel=defaultModelSet().entityNamed('Mothers').relationshipNamed('toProvince')
# Now fetch all provinces of mothers in a single fetch
dbContext.batchFetchRelationship(rel, mothers, EC)
for mother in mothers:
id=mother.getMothersId()
date=mother.getBirthDate()
province=mother.gettoProvince().getName()
---------------------
(It's Sebastien's code but he make some little mistakes.)
> I should probably add this feature to the framework, it's been
> regularly asked. Do we want this in the next release?
> [...]
> PS: as I said it previously when I sent the first version of the patch,
> this is not the definitive user-friendly interface ;) There will
> probably be a more convenient method at the EditingContext level,
> something like ec.batchFetch(mothers, 'toProvince') e.g.
It's a VERY good idea.
And a question about patches. How to include patch to the file. Now I just
copy the code from .patch file to .py file. It is propably some way to do it
automaticaly with WinCVS, but I dont know how.
****************************
* Lukasz Lakomy
* luk...@po...
****************************
|