<?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: PHP/MySQL Efficient Paged Data</title>
	<atom:link href="http://www.vinylfox.com/phpmysql-efficient-paged-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vinylfox.com/phpmysql-efficient-paged-data/</link>
	<description>The Playground of VinylFox (Shea Frederick)</description>
	<lastBuildDate>Tue, 31 Aug 2010 20:03:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Shea Frederick</title>
		<link>http://www.vinylfox.com/phpmysql-efficient-paged-data/comment-page-1/#comment-6269</link>
		<dc:creator>Shea Frederick</dc:creator>
		<pubDate>Fri, 26 Feb 2010 20:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://ww2.vinylfox.com/?p=32#comment-6269</guid>
		<description>Im just not seeing your point here. Did you see the last sentence in this post?

&quot;This could change based on your dataset, for instance the third method might turn out to be the best in a situation where you dont have many rows in your table. There are also situations where the first method would run much slower than the second.&quot;</description>
		<content:encoded><![CDATA[<p>Im just not seeing your point here. Did you see the last sentence in this post?</p>
<p>&#8220;This could change based on your dataset, for instance the third method might turn out to be the best in a situation where you dont have many rows in your table. There are also situations where the first method would run much slower than the second.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl</title>
		<link>http://www.vinylfox.com/phpmysql-efficient-paged-data/comment-page-1/#comment-6058</link>
		<dc:creator>Carl</dc:creator>
		<pubDate>Sat, 13 Feb 2010 18:07:16 +0000</pubDate>
		<guid isPermaLink="false">http://ww2.vinylfox.com/?p=32#comment-6058</guid>
		<description>Shea,

I read the post, but for me it&#039;s probably logical to run 2 queries for a count and a record selection. I work with a separated mysql cluster (a master and 2 slaves) We use the master for writing only (if possible) and the slaves for reading. We need to take bandwith into account.

So a complete table dump to get a record count is strictly &quot;not done&quot;. It&#039;s a &#039;SELECT count(*)&#039;, and after it&#039;s a &#039;SELECT whatevercolumnsonewants FROM whatevertable WHERE clause LIMIT start, end&#039;. That&#039;s fastest as we found out. We work for a number of publishers which are using vouchers to obtain licenses for &#039;Electronic Study Systems&#039; (which is just another word for &#039;learning by PC&#039;). The registered students are currently near 400K, the vouchers number in millions, so indexes must be right and just enough - too many an index gives also a performance problem.

 Using PHP to sort, limit or whatever manipulation on a dataset from MySQL, not done if it can be avoided. It will not be as fast as a tuned MySQLserver can do it, the latter is often - if not always - the case for poor database performance.

Carl</description>
		<content:encoded><![CDATA[<p>Shea,</p>
<p>I read the post, but for me it&#8217;s probably logical to run 2 queries for a count and a record selection. I work with a separated mysql cluster (a master and 2 slaves) We use the master for writing only (if possible) and the slaves for reading. We need to take bandwith into account.</p>
<p>So a complete table dump to get a record count is strictly &#8220;not done&#8221;. It&#8217;s a &#8216;SELECT count(*)&#8217;, and after it&#8217;s a &#8216;SELECT whatevercolumnsonewants FROM whatevertable WHERE clause LIMIT start, end&#8217;. That&#8217;s fastest as we found out. We work for a number of publishers which are using vouchers to obtain licenses for &#8216;Electronic Study Systems&#8217; (which is just another word for &#8216;learning by PC&#8217;). The registered students are currently near 400K, the vouchers number in millions, so indexes must be right and just enough &#8211; too many an index gives also a performance problem.</p>
<p> Using PHP to sort, limit or whatever manipulation on a dataset from MySQL, not done if it can be avoided. It will not be as fast as a tuned MySQLserver can do it, the latter is often &#8211; if not always &#8211; the case for poor database performance.</p>
<p>Carl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shea Frederick</title>
		<link>http://www.vinylfox.com/phpmysql-efficient-paged-data/comment-page-1/#comment-6042</link>
		<dc:creator>Shea Frederick</dc:creator>
		<pubDate>Fri, 12 Feb 2010 15:06:51 +0000</pubDate>
		<guid isPermaLink="false">http://ww2.vinylfox.com/?p=32#comment-6042</guid>
		<description>Carl - im not sure if you actually read this post or looked at the code, because I never use a &#039;select *&#039; anywhere in my tests. Sorry that annoys you. 

My comparison is equal, because I wanted to know the quickest way to return paged data and a record count, and that&#039;s what all of the examples do.

As for testing band with, that is completely out of my control, therefore not included in the test (im using localhost).

Thanks for the tip on double/single quotes.</description>
		<content:encoded><![CDATA[<p>Carl &#8211; im not sure if you actually read this post or looked at the code, because I never use a &#8216;select *&#8217; anywhere in my tests. Sorry that annoys you. </p>
<p>My comparison is equal, because I wanted to know the quickest way to return paged data and a record count, and that&#8217;s what all of the examples do.</p>
<p>As for testing band with, that is completely out of my control, therefore not included in the test (im using localhost).</p>
<p>Thanks for the tip on double/single quotes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl</title>
		<link>http://www.vinylfox.com/phpmysql-efficient-paged-data/comment-page-1/#comment-6041</link>
		<dc:creator>Carl</dc:creator>
		<pubDate>Fri, 12 Feb 2010 09:38:31 +0000</pubDate>
		<guid isPermaLink="false">http://ww2.vinylfox.com/?p=32#comment-6041</guid>
		<description>Nice examples, however, a count(*) is always faster than selected columns and a start/limit clause. The filtering of columns to exclude/include takes time.

Furthermore, depending on your mysql server in the network - localhost or on another host - you wil find larger differences between outcomes due to band width.

The thing which annoys me is the comparrisons you make. Your compare statements are not equal, and therefore will always show a difference in execution time. A &#039;count(*)&#039; needs less bandwidth compared to a &#039;select *&#039;, as a count has only 1 record and a &#039;select *&#039; has x records. It would be better if you had done a test on &#039;select * from ... LIMITstart, end&#039;  vs &#039;select column_name_1, column_name_n, ... FROM ... LIMIT start, end&#039;. Than compare an unordered query, one ordered ASC and onother DESC and find the difference. Use a table with say 6,500,000 records ... and compare it against queries run against a table with 1,000.

(Why do you use double quotes around your sql statements! It&#039;s better to use single quotes in PHP code;  concat strings/variables/constants escape required single quotes. It won&#039;t show much different on sites with little visitors, but when you get 100+ per minute you definitely will notice the difference.)</description>
		<content:encoded><![CDATA[<p>Nice examples, however, a count(*) is always faster than selected columns and a start/limit clause. The filtering of columns to exclude/include takes time.</p>
<p>Furthermore, depending on your mysql server in the network &#8211; localhost or on another host &#8211; you wil find larger differences between outcomes due to band width.</p>
<p>The thing which annoys me is the comparrisons you make. Your compare statements are not equal, and therefore will always show a difference in execution time. A &#8216;count(*)&#8217; needs less bandwidth compared to a &#8216;select *&#8217;, as a count has only 1 record and a &#8216;select *&#8217; has x records. It would be better if you had done a test on &#8216;select * from &#8230; LIMITstart, end&#8217;  vs &#8216;select column_name_1, column_name_n, &#8230; FROM &#8230; LIMIT start, end&#8217;. Than compare an unordered query, one ordered ASC and onother DESC and find the difference. Use a table with say 6,500,000 records &#8230; and compare it against queries run against a table with 1,000.</p>
<p>(Why do you use double quotes around your sql statements! It&#8217;s better to use single quotes in PHP code;  concat strings/variables/constants escape required single quotes. It won&#8217;t show much different on sites with little visitors, but when you get 100+ per minute you definitely will notice the difference.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
