Hi Oleg,

Thank you for the clear explanation. I've added some comments and
questions below :

Le mardi 01 août 2006 à 12:32 +0400, Oleg Broytmann a écrit :
> On Tue, Aug 01, 2006 at 07:47:48AM +0200, Didrik Pinte wrote:
> > [1] vdata = validdata.select(AND(validdata.q.stationID == station.id,
> > validdata.q.mtime == row.mtime))[0]
> > 
> > then I parse the states in this row with the following code :
> > 
> > [2] for state in states:
> >     getattr(vdata, state)
> > 
> > My understanding is that vdata is a SelectResults and that the
> 
>    Wrong. You have used [0] to index the SelectResults object and hence get
> an SQLObject instance.

You're right. I understood it after having send the message to the
list...

> 
> > It seems that for each getattr(vdata, state) there is a new call to the
> > database.
> 
>    Because you are fetching data via ForeignKey columns, and SQLObject
> doesn't cache them (but it caches the referenced rows).

Ok, so it means that the following code will always require two queries
in the same table in order to get the foreign key value ?

# select the row
vdata = validata.select(AND(validdata.q.stationID == station.id,
validdata.q.mtime == row.mtime))[0]
# get the tha state id
vdata.tha_state_id

That's why it's so slow. I've 4.10^6 rows with 8 states per row. That
means 7* 4.10^6 unwanted queries.

Is there a more efficent way to do that using direct sqlobject calls ?
Otherwise, I will use sqlbuilder and fetch the 8 states in one time.

--
Didrik


Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to