<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Querying With NHibernate</title>
	<atom:link href="http://davybrion.com/blog/2008/10/querying-with-nhibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Tue, 16 Mar 2010 21:33:15 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3234</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Mon, 06 Oct 2008 07:08:50 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3234</guid>
		<description>heh, now this is interesting... one of our database specialists at work told me that subqueries were indeed not the best way to fetch the data

so we compared the performance of the query with the subqueries, compared to one that uses only joins (and some variations on that)

in each case, the one with subqueries performed better :)

i think it&#039;s because the resultset of the subqueries is in this case the same for each row in the main query.  if the subqueries where using values of the rows in the main query, the join approach would probably be a lot faster i think</description>
		<content:encoded><![CDATA[<p>heh, now this is interesting&#8230; one of our database specialists at work told me that subqueries were indeed not the best way to fetch the data</p>
<p>so we compared the performance of the query with the subqueries, compared to one that uses only joins (and some variations on that)</p>
<p>in each case, the one with subqueries performed better <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>i think it&#8217;s because the resultset of the subqueries is in this case the same for each row in the main query.  if the subqueries where using values of the rows in the main query, the join approach would probably be a lot faster i think</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #194</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3233</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #194</dc:creator>
		<pubDate>Mon, 06 Oct 2008 07:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3233</guid>
		<description>[...] Querying With NHibernate - Davy Brion explores the construction of complex queries in NHibernate using the criteria API, including looking at creating sub queries, and compares the underlying SQL to a hand crafted original. [...]</description>
		<content:encoded><![CDATA[<p>[...] Querying With NHibernate &#8211; Davy Brion explores the construction of complex queries in NHibernate using the criteria API, including looking at creating sub queries, and compares the underlying SQL to a hand crafted original. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3195</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Sun, 05 Oct 2008 11:37:08 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3195</guid>
		<description>yeah, i&#039;d usually try to do it with joins instead of any subqueries as well. But as far as i know (and if someone can correct this, please do so) you can only join on associations that have been mapped with NHibernate. So joining on &#039;dynamically&#039; composed resultsets is something that is not possible, unless i&#039;m mistaken. Maybe someone else can shed more light on this :)

Having said that, i&#039;d like to know which aproach is better: the joins or the subqueries. Theoritically speaking, i&#039;d think the join approach is better. But these days, you&#039;re never really sure how the DB is going to optimize the query when it&#039;s actually being executed so i wouldn&#039;t be surprised if the subquery approach turns out to be just as fast as the joined approach.</description>
		<content:encoded><![CDATA[<p>yeah, i&#8217;d usually try to do it with joins instead of any subqueries as well. But as far as i know (and if someone can correct this, please do so) you can only join on associations that have been mapped with NHibernate. So joining on &#8216;dynamically&#8217; composed resultsets is something that is not possible, unless i&#8217;m mistaken. Maybe someone else can shed more light on this <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Having said that, i&#8217;d like to know which aproach is better: the joins or the subqueries. Theoritically speaking, i&#8217;d think the join approach is better. But these days, you&#8217;re never really sure how the DB is going to optimize the query when it&#8217;s actually being executed so i wouldn&#8217;t be surprised if the subquery approach turns out to be just as fast as the joined approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: disco stu</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3194</link>
		<dc:creator>disco stu</dc:creator>
		<pubDate>Sun, 05 Oct 2008 11:27:11 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3194</guid>
		<description>scratch that! =&gt; like this

&lt;code&gt;select
	customer.CustomerId,
	customer.CompanyName,
	customer.ContactName,
	customer.ContactTitle,
	customer.Address,
	customer.City,
	customer.Region,
	customer.PostalCode,
	customer.Country,
	customer.Phone,
	customer.Fax
from
	Customers Customer
	join (
	select distinct
		Orders.CustomerID
	from
		Orders
		join [Order Details] on [Order Details].OrderID = Orders.OrderID
	where
		[Order Details].ProductID = 24) ProductCustomer on ProductCustomer.CustomerID = Customer.ID&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>scratch that! =&gt; like this</p>
<p><code>select<br />
	customer.CustomerId,<br />
	customer.CompanyName,<br />
	customer.ContactName,<br />
	customer.ContactTitle,<br />
	customer.Address,<br />
	customer.City,<br />
	customer.Region,<br />
	customer.PostalCode,<br />
	customer.Country,<br />
	customer.Phone,<br />
	customer.Fax<br />
from<br />
	Customers Customer<br />
	join (<br />
	select distinct<br />
		Orders.CustomerID<br />
	from<br />
		Orders<br />
		join [Order Details] on [Order Details].OrderID = Orders.OrderID<br />
	where<br />
		[Order Details].ProductID = 24) ProductCustomer on ProductCustomer.CustomerID = Customer.ID</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: disco stu</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3193</link>
		<dc:creator>disco stu</dc:creator>
		<pubDate>Sun, 05 Oct 2008 11:25:47 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3193</guid>
		<description>Disco Stu would do it like this:
&lt;code&gt;select
	customer.CustomerId,
	customer.CompanyName,
	customer.ContactName,
	customer.ContactTitle,
	customer.Address,
	customer.City,
	customer.Region,
	customer.PostalCode,
	customer.Country,
	customer.Phone,
	customer.Fax
from
	Customers Customer
	join (
	select
		Orders.CustomerID
	from
		Orders
		join [Order Details] on [Order Details].OrderID = Orders.OrderID
	where
		[Order Details].ProductID = 24
	group by
		Orders.CustomerID) ProductCustomer on ProductCustomer.CustomerID = Customer.ID&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Disco Stu would do it like this:<br />
<code>select<br />
	customer.CustomerId,<br />
	customer.CompanyName,<br />
	customer.ContactName,<br />
	customer.ContactTitle,<br />
	customer.Address,<br />
	customer.City,<br />
	customer.Region,<br />
	customer.PostalCode,<br />
	customer.Country,<br />
	customer.Phone,<br />
	customer.Fax<br />
from<br />
	Customers Customer<br />
	join (<br />
	select<br />
		Orders.CustomerID<br />
	from<br />
		Orders<br />
		join [Order Details] on [Order Details].OrderID = Orders.OrderID<br />
	where<br />
		[Order Details].ProductID = 24<br />
	group by<br />
		Orders.CustomerID) ProductCustomer on ProductCustomer.CustomerID = Customer.ID</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Querying With NHibernate - NHibernate blog - NHibernate Forge</title>
		<link>http://davybrion.com/blog/2008/10/querying-with-nhibernate/comment-page-1/#comment-3191</link>
		<dc:creator>Querying With NHibernate - NHibernate blog - NHibernate Forge</dc:creator>
		<pubDate>Sun, 05 Oct 2008 11:06:09 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=480#comment-3191</guid>
		<description>[...] NOTE: this was originally posted on my own blog [...]</description>
		<content:encoded><![CDATA[<p>[...] NOTE: this was originally posted on my own blog [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
