Wanted to make sure I'm not missing something here:

Right now I have this configuration:

------------------------------------

<object name="Newsletter" alias="newsletter">
  <hasMany name="Article">
   <relate from="newsletterId" to="newsletterId" />
  </hasMany>
</object>

<object name="Article" alias="article">
  <hasOne name="Image">
    <relate from="imageId" to="imageId" />
  </hasOne>
  <hasOne name="Newsletter">
    <relate from="newsletterId" to="newsletterId" />
  </hasOne>
  <hasOne name="Category">
    <relate from="categoryId" to="categoryId" />
  </hasOne>
</object>

<object name="Image" alias="image" />

------------------------------------


And I'm running this code:

------------------------------------

<cfset curArticle =
application.serviceFactory.getBean('articleService').getLeadArticle() />
<cfset request.title = curArticle.getTitle() />
<cfset request.pageSubtitle = curArticle.getCategory().getCategoryName() />
<cfset request.pageImageId = curArticle.getImageId() />
<cfset request.pageImageType = curArticle.getImage().getImageType() />
<cfset request.pageDate = curArticle.getNewsletter().getNewsletterDate() />
<cfset request.pageImageAlt = curArticle.getImage().getFriendlyName() />

------------------------------------


Which is resulting in a total of FOUR queries being run:

------------------------------------

(1)

SELECT  [article].[articleId] AS [articleId],  [article].[newsletterId] AS
[newsletterId],  [article].[categoryId] AS [categoryId],  [article].[title]
AS [title],  [article].[body] AS [body],  [article].[imageId] AS [imageId],
[article].[isLead] AS [isLead],  [article].[crd] AS [crd] FROM [Article] AS
[article] WHERE [article].[articleId] = ?

(2)

SELECT  [Category].[categoryId] AS [categoryId],  [Category].[categoryName]
AS [categoryName],  [Category].[crd] AS [crd] FROM [Category] AS [Category]
WHERE [Category].[categoryId] = ? 

(3)

SELECT  [image].[imageId] AS [imageId],  [image].[imageType] AS [imageType],
[image].[friendlyName] AS [friendlyName],  [image].[crd] AS [crd] FROM
[Image] AS [image] WHERE [image].[imageId] = ? 

(4)

SELECT  [newsletter].[newsletterId] AS [newsletterId],
[newsletter].[newsletterDate] AS [newsletterDate],  [newsletter].[crd] AS
[crd] FROM [Newsletter] AS [newsletter] WHERE [newsletter].[newsletterId] =
?  

------------------------------------


And the only way to make this more efficient (reducing it to a single query)
would be to write a custom query in one of the user-editable CFCs in my data
directory?

Another way that I'd considered making this more efficient was to somehow
cache the above queries, but I don't know how to do that with reactor...

I would like to reduce the number of database calls here, as I believe this
particular function is going to receive a lot of traffic.  I ran into
trouble in the past with my use of reactor not holding up under traffic, and
clearly I don't really need four database calls here, if I had a query that
returned all the data in one object somehow...

Can anyone point me in the right direction or offer advice on this?

Thanks,

M









-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to