<?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: The Secret of SQL_CALC_FOUND_ROWS</title>
	<atom:link href="http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/</link>
	<description>Stuff only Michi cares to read</description>
	<lastBuildDate>Sun, 22 Jan 2012 10:48:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Tim</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-15123</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Thu, 21 Jan 2010 17:59:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-15123</guid>
		<description>btw: LIMIT 2,1 will return the third row, not the second row.</description>
		<content:encoded><![CDATA[<p>btw: LIMIT 2,1 will return the third row, not the second row.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-15119</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Tue, 19 Jan 2010 05:17:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-15119</guid>
		<description>This is not &quot;definitely faster&quot; than using count(*).  In fact, when I tried it, the result was many times slower than the original two queries combined.

From the comments on http://dev.mysql.com/doc/refman/5.0/en/information-functions.html
Posted by Wade Bowmer on May 14 2006 11:40pm
Be aware that using SQL_CALC_FOUND_ROWS and FOUND_ROWS() disables ORDER BY ... LIMIT optimizations (see bugs http://bugs.mysql.com/bug.php?id=18454 and http://bugs.mysql.com/bug.php?id=19553). Until it&#039;s fixed, you should run your own benchmarks with and without it.</description>
		<content:encoded><![CDATA[<p>This is not &#8220;definitely faster&#8221; than using count(*).  In fact, when I tried it, the result was many times slower than the original two queries combined.</p>
<p>From the comments on <a href="http://dev.mysql.com/doc/refman/5.0/en/information-functions.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/information-functions.html</a><br />
Posted by Wade Bowmer on May 14 2006 11:40pm<br />
Be aware that using SQL_CALC_FOUND_ROWS and FOUND_ROWS() disables ORDER BY &#8230; LIMIT optimizations (see bugs <a href="http://bugs.mysql.com/bug.php?id=18454" rel="nofollow">http://bugs.mysql.com/bug.php?id=18454</a> and <a href="http://bugs.mysql.com/bug.php?id=19553" rel="nofollow">http://bugs.mysql.com/bug.php?id=19553</a>). Until it&#8217;s fixed, you should run your own benchmarks with and without it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michi</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6858</link>
		<dc:creator>Michi</dc:creator>
		<pubDate>Wed, 08 Aug 2007 16:05:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6858</guid>
		<description>of course. but in many cases, knowing a general total is &quot;good enough.&quot; facebook did this. even google does this. in cases where knowing the exact total in a constantly changing table is a requirement, you would obviously avoid this solution. however, in a 40 million record result set for a search, being off one or two is no big deal. however, reducing subsequent page loads (after the caching) from 5 minutes down to 0.2 seconds IS a big deal.</description>
		<content:encoded><![CDATA[<p>of course. but in many cases, knowing a general total is &#8220;good enough.&#8221; facebook did this. even google does this. in cases where knowing the exact total in a constantly changing table is a requirement, you would obviously avoid this solution. however, in a 40 million record result set for a search, being off one or two is no big deal. however, reducing subsequent page loads (after the caching) from 5 minutes down to 0.2 seconds IS a big deal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jason</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6814</link>
		<dc:creator>jason</dc:creator>
		<pubDate>Wed, 08 Aug 2007 12:17:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6814</guid>
		<description>Correct me if I&#039;m wrong, but in relation to Ben&#039;s question about safety: if you do cache the total number of rows in the URL you need to be careful in instances where other users might be making submissions to the database. That could cause a scenario where user A&#039;s session thinks there are a total of 100 rows, but user B just added 10 more. If user A is viewing all of those records with a paginated navigation, that there&#039;s the potential for conflicts and you&#039;d need to plan/code accordingly.</description>
		<content:encoded><![CDATA[<p>Correct me if I&#8217;m wrong, but in relation to Ben&#8217;s question about safety: if you do cache the total number of rows in the URL you need to be careful in instances where other users might be making submissions to the database. That could cause a scenario where user A&#8217;s session thinks there are a total of 100 rows, but user B just added 10 more. If user A is viewing all of those records with a paginated navigation, that there&#8217;s the potential for conflicts and you&#8217;d need to plan/code accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michi</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6706</link>
		<dc:creator>Michi</dc:creator>
		<pubDate>Tue, 07 Aug 2007 23:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6706</guid>
		<description>It is safe. It is session specific. &quot;session&quot; means for a single connection instance (such as a page load). It does not persist, and it is not shared (unless you are using connection pooling).

You &quot;flush&quot; it by making a new SELECT query statement. From the MySQL documentation:

&quot;In the absence of the SQL_CALC_FOUND_ROWS option in the most recent SELECT statement, FOUND_ROWS() returns the number of rows in the result set returned by that statement.&quot;</description>
		<content:encoded><![CDATA[<p>It is safe. It is session specific. &#8220;session&#8221; means for a single connection instance (such as a page load). It does not persist, and it is not shared (unless you are using connection pooling).</p>
<p>You &#8220;flush&#8221; it by making a new SELECT query statement. From the MySQL documentation:</p>
<p>&#8220;In the absence of the SQL_CALC_FOUND_ROWS option in the most recent SELECT statement, FOUND_ROWS() returns the number of rows in the result set returned by that statement.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Cornwell</title>
		<link>http://www.michikono.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6688</link>
		<dc:creator>Ben Cornwell</dc:creator>
		<pubDate>Tue, 07 Aug 2007 21:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/08/07/the-secret-of-sql_calc_found_rows/#comment-6688</guid>
		<description>Sounds interesting, but how safe is it? Can it be realistically relied upon where you have more than one user accessing the db? Does the calculated value persist between different and/or subsequent connections? 

Also, how do you flush the value when you change the where clause?</description>
		<content:encoded><![CDATA[<p>Sounds interesting, but how safe is it? Can it be realistically relied upon where you have more than one user accessing the db? Does the calculated value persist between different and/or subsequent connections? </p>
<p>Also, how do you flush the value when you change the where clause?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Object Caching 406/410 objects using disk: basic

Served from: www.michikono.com @ 2012-02-10 16:12:55 -->
