[Zope] ZSQLMethods

Chris Gray cpgray@library.uwaterloo.ca
Mon, 4 Dec 2000 11:28:08 -0500 (EST)


Right, Phil.  Mental lapse on my part.

The nested dtml-ins will be very inefficient because the select on the
whole of table2 in the inner one will be repeated once for each record in
table1.  I was thinking it would only get executed once.

The first solution I offered is better especially if table2 is indexed on
id, but you're still executing a repeated query on table2.

<dtml-in selectFromTable1>
  <dtml-in expr="selectFromTable2(id=_['id'])">
     ....display record....
  </dtml-in>
</dtml-in>

Chris


On Mon, 4 Dec 2000, Phil Harris wrote:

> Depending on the number of records in the tables this could get *very* slow
> *very* quickly.
> 
> Surely the ideal would be to move/copy the tables into the same DB.
> 
> Phil
> 
> ----- Original Message -----
> From: "Chris Gray" <cpgray@library.uwaterloo.ca>
> To: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be>
> Cc: <zope@zope.org>
> Sent: Monday, December 04, 2000 3:21 PM
> Subject: Re: [Zope] ZSQLMethods
> 
> 
> > Try something like:
> >
> > <dtml-in selectFromTable1>
> >   <dtml-in selectFromTable2>
> >      <dtml-if idFromTable1 = idFromTable2>
> >         ....display parts of the two records....
> >      </dtml-if>
> >   </dtml-in>
> > </dtml-in>
> >
> > This keeps it to two db queries and the join work is done by Zope.
> >
> > Chris
> >
> > On Mon, 4 Dec 2000, Tom Deprez wrote:
> >
> > > Hi Chris,
> > >
> > > Thanks, is this code still efficient if the tables relate to 1:1 and you
> > > need to show a list of all records in a tabulare table?
> > >
> > > eg key, NAME, ALIAS, ....
> > >
> > > where NAME is from database1 and ALIAS is from database2
> > >
> > > The code below would impact that for every record in database1, I've to
> > > query database2
> > > Is there another way to do this? (more efficient?, ie less database
> query)
> > >
> > > Tom.
> > >
> > > ----- Original Message -----
> > > From: "Chris Gray" <cpgray@library.uwaterloo.ca>
> > > To: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be>
> > > Cc: <zope@zope.org>
> > > Sent: Monday, December 04, 2000 3:45 PM
> > > Subject: Re: [Zope] ZSQLMethods
> > >
> > >
> > > > You want something along these lines:
> > > >
> > > > <dtml-in selectFromTable1>
> > > >    <dtml-in expr="selectFromTable2(id=_['id'])">
> > > >       ....display record....
> > > >    </dtml-in>
> > > > </dtml-in>
> > > >
> > > > This would be more efficient than pulling out the whole of two tables.
> > > >
> > > > Chris
> > > >
> > > > On Mon, 4 Dec 2000, Tom Deprez wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I'm wondering how the following can be done.
> > > > >
> > > > > I've 2 databases. I want to do a 'join' with 2 tables, both in a
> > > different
> > > > > database.
> > > > > Is it possible to retrieve data of both tables with a ZSQLMethod and
> > > then
> > > > > do a programatically join? What's the easiest python way?
> > > > >
> > > > > Thanks, Tom.
> > > > >
> > > > > _______________________________________________
> > > > > Zope maillist  -  Zope@zope.org
> > > > > http://lists.zope.org/mailman/listinfo/zope
> > > > > **   No cross posts or HTML encoding!  **
> > > > > (Related lists -
> > > > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > > > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Zope maillist  -  Zope@zope.org
> > > > http://lists.zope.org/mailman/listinfo/zope
> > > > **   No cross posts or HTML encoding!  **
> > > > (Related lists -
> > > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> > > >
> > >
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>