<?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: Using the extra() QuerySet modifier in Django for WeGoEat</title>
	<atom:link href="http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/</link>
	<description>Everything you&#039;ve ever thought, but never had the balls to say.</description>
	<lastBuildDate>Tue, 22 Nov 2011 07:17:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: DROP DB blogs</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-30233</link>
		<dc:creator>DROP DB blogs</dc:creator>
		<pubDate>Fri, 01 Oct 2010 23:49:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-30233</guid>
		<description>BTW, fix your code formatting. You&#039;re escaping HTML entities twice.</description>
		<content:encoded><![CDATA[<p>BTW, fix your code formatting. You&#8217;re escaping HTML entities twice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryankanno</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8785</link>
		<dc:creator>ryankanno</dc:creator>
		<pubDate>Fri, 26 Oct 2007 01:16:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8785</guid>
		<description>@Matt - 

Actually, last night I worked on denormalizing the tables and using a post.save signal, whenever a Review is added, the Restaurant instance associated saves itself which in turn updates a few columns, one being called &quot;average_review&quot; (just as Ross/Jeff suggested).  Thanks for the comment though - I love all the help the community provides; especially for us techies in remote places. :)</description>
		<content:encoded><![CDATA[<p>@Matt &#8211; </p>
<p>Actually, last night I worked on denormalizing the tables and using a post.save signal, whenever a Review is added, the Restaurant instance associated saves itself which in turn updates a few columns, one being called &#8220;average_review&#8221; (just as Ross/Jeff suggested).  Thanks for the comment though &#8211; I love all the help the community provides; especially for us techies in remote places. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8783</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 26 Oct 2007 00:14:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8783</guid>
		<description>Not sure that you want to be doing an AVG and/or COUNT on every request - might be better (at a certain point) to start using summary tables. Thanks for the post, though!</description>
		<content:encoded><![CDATA[<p>Not sure that you want to be doing an AVG and/or COUNT on every request &#8211; might be better (at a certain point) to start using summary tables. Thanks for the post, though!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trent</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8743</link>
		<dc:creator>Trent</dc:creator>
		<pubDate>Thu, 25 Oct 2007 13:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8743</guid>
		<description>Your website is very niceI just wish I could pick it apart and find all the little faults in it that you never thought about. Like you do to my things. But I can&#039;t</description>
		<content:encoded><![CDATA[<p>Your website is very niceI just wish I could pick it apart and find all the little faults in it that you never thought about. Like you do to my things. But I can&#8217;t</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Empty</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8717</link>
		<dc:creator>Empty</dc:creator>
		<pubDate>Thu, 25 Oct 2007 04:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8717</guid>
		<description>Nice post.  Extra is really useful but sometimes takes some work to get it to do what you want. I agree with Ross, I would likely denomalize this, especially if I expected to generate any significant traffic.</description>
		<content:encoded><![CDATA[<p>Nice post.  Extra is really useful but sometimes takes some work to get it to do what you want. I agree with Ross, I would likely denomalize this, especially if I expected to generate any significant traffic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross Poulton</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8716</link>
		<dc:creator>Ross Poulton</dc:creator>
		<pubDate>Thu, 25 Oct 2007 04:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8716</guid>
		<description>:)

I can&#039;t take all the credit for it, the idea first came into my head when I saw it in the &lt;a href=&#039;http://www2.jeffcroft.com/blog/2007/may/28/lost-theoriescom-source-code-update/&#039; rel=&quot;nofollow&quot;&gt;Lost Theories source code that Jeff Croft made available&lt;/a&gt;.

It works very well, and it&#039;s the way I&#039;ve handle sorting by # comments and ratings on &lt;a href=&#039;http://www.djangosites.org/latest/&#039; rel=&quot;nofollow&quot;&gt;Django Sites&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p> <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I can&#8217;t take all the credit for it, the idea first came into my head when I saw it in the <a href='http://www2.jeffcroft.com/blog/2007/may/28/lost-theoriescom-source-code-update/' rel="nofollow">Lost Theories source code that Jeff Croft made available</a>.</p>
<p>It works very well, and it&#8217;s the way I&#8217;ve handle sorting by # comments and ratings on <a href='http://www.djangosites.org/latest/' rel="nofollow">Django Sites</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryankanno</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8712</link>
		<dc:creator>ryankanno</dc:creator>
		<pubDate>Thu, 25 Oct 2007 00:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8712</guid>
		<description>@Ross -

By far the best suggestion yet! :)  I hadn&#039;t even begun to think of denormalizing the database at all!  &lt;strike&gt;+1&lt;/strike&gt; +100 for Ross. :P  I&#039;ll be working on the signal tonight.  Gosh, community rocks!</description>
		<content:encoded><![CDATA[<p>@Ross -</p>
<p>By far the best suggestion yet! <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I hadn&#8217;t even begun to think of denormalizing the database at all!  <strike>+1</strike> +100 for Ross. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />   I&#8217;ll be working on the signal tonight.  Gosh, community rocks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross Poulton</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8711</link>
		<dc:creator>Ross Poulton</dc:creator>
		<pubDate>Thu, 25 Oct 2007 00:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8711</guid>
		<description>That&#039;s a neat use of the extra() function; however I believe this may be a case for database de-normalisation. The most efficient way of doing this is probably to add an &#039;avg_rating&#039; field to your Restaurant model, and use a signal so that whenever a review is saved, you re-calculate the average rating for that Restaurant and save it directly on the model.

There is a huge upside to this de-normalised method: You can use sort_by() or limit() to only show restaurants that have a rating above 4, or sort them by rating.

Lastly, it should produce more portable code, as subselects may or may not work the same way on different database servers.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a neat use of the extra() function; however I believe this may be a case for database de-normalisation. The most efficient way of doing this is probably to add an &#8216;avg_rating&#8217; field to your Restaurant model, and use a signal so that whenever a review is saved, you re-calculate the average rating for that Restaurant and save it directly on the model.</p>
<p>There is a huge upside to this de-normalised method: You can use sort_by() or limit() to only show restaurants that have a rating above 4, or sort them by rating.</p>
<p>Lastly, it should produce more portable code, as subselects may or may not work the same way on different database servers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryankanno</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8710</link>
		<dc:creator>ryankanno</dc:creator>
		<pubDate>Wed, 24 Oct 2007 23:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8710</guid>
		<description>I definitely agree that the SQL makes subselects for every row.  

Since I&#039;m no database guru, I&#039;ll profile it under SQL analyzer to see how bad/optimized it is.  Yet, I don&#039;t think Django is the problem here at all.  If anything, it&#039;s me as the developer, and if you were trying to be nice about it... Thanks! :) If I knew the optimized SQL to write, I would. ;)

Maybe the optimal thing to do is to perform the query to retrieve the objects, then perform the average call, then merge the data QuerySet&#039;s together... :P</description>
		<content:encoded><![CDATA[<p>I definitely agree that the SQL makes subselects for every row.  </p>
<p>Since I&#8217;m no database guru, I&#8217;ll profile it under SQL analyzer to see how bad/optimized it is.  Yet, I don&#8217;t think Django is the problem here at all.  If anything, it&#8217;s me as the developer, and if you were trying to be nice about it&#8230; Thanks! <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If I knew the optimized SQL to write, I would. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Maybe the optimal thing to do is to perform the query to retrieve the objects, then perform the average call, then merge the data QuerySet&#8217;s together&#8230; <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julian</title>
		<link>http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/comment-page-1/#comment-8709</link>
		<dc:creator>Julian</dc:creator>
		<pubDate>Wed, 24 Oct 2007 22:30:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/10/24/using-the-extra-queryset-modifier-in-django-for-wegoeat/#comment-8709</guid>
		<description>It is definitely an improvement. But showing it as a good solution and blog about it is not. This SQL still makes subselects, for every single row. The real problem is Django in this case, we should focus on that, instead of praising workarounds which circumvent real SQL solutions.</description>
		<content:encoded><![CDATA[<p>It is definitely an improvement. But showing it as a good solution and blog about it is not. This SQL still makes subselects, for every single row. The real problem is Django in this case, we should focus on that, instead of praising workarounds which circumvent real SQL solutions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: blog.localkinegrinds.com @ 2012-02-07 21:43:51 -->
