<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[Content with Style - Comments on quick MySQL nice-to-know]]></title>
    <link>http://www.contentwithstyle.co.uk/feeds/rss/comments/104</link>
    <description><![CDATA[]]></description>
    <pubDate>Tue, 06 Jan 2009 07:48:21 +0000</pubDate>
    <generator>Zend_Feed</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Content with Style - Comment #1 on quick MySQL nice-to-know]]></title>
      <link>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-641</link>
      <guid>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-641</guid>
      <description><![CDATA[I am not suprised that a specific join (inner, left or right) is somewhat faster than a cartesian product. As already stated in the link you give, the where clause is executed at the end as filter and not as first as restriction, with the use of join you will restrict your results first. What however is also remarkable of MySQL is this:<br />
<br />
&#8220;Note that INNER JOIN syntax allows a join_condition only from MySQL 3.23.17 on. The same is true for JOIN and CROSS JOIN only as of MySQL 4.0.11.&#8221;<br />
<br />
So in versions before 4.0.11 you should use &#8220;INNER JOIN&#8221; and you were not able to use the &#8220;JOIN&#8221; for any natural joins.<br />
<br />
When using replace is can become rather ineffective if you have large tables (really large ;)) with indexes. While REPLACE INTO looks like it either performs an update or an insert it will executed in both cases as an insert. If the row exists it will first delete the row and after the delete it will insert the &#8216;new&#8217; row. If you have a large table with rather large indexes both the insert as the delete wil have an impact on the rebuild of your index. Using a simple select to check if the row exists and if so perform an update is with large tables far more effectient and is worth benchmarking on small tables]]></description>
      <content:encoded><![CDATA[I am not suprised that a specific join (inner, left or right) is somewhat faster than a cartesian product. As already stated in the link you give, the where clause is executed at the end as filter and not as first as restriction, with the use of join you will restrict your results first. What however is also remarkable of MySQL is this:<br />
<br />
&#8220;Note that INNER JOIN syntax allows a join_condition only from MySQL 3.23.17 on. The same is true for JOIN and CROSS JOIN only as of MySQL 4.0.11.&#8221;<br />
<br />
So in versions before 4.0.11 you should use &#8220;INNER JOIN&#8221; and you were not able to use the &#8220;JOIN&#8221; for any natural joins.<br />
<br />
When using replace is can become rather ineffective if you have large tables (really large ;)) with indexes. While REPLACE INTO looks like it either performs an update or an insert it will executed in both cases as an insert. If the row exists it will first delete the row and after the delete it will insert the &#8216;new&#8217; row. If you have a large table with rather large indexes both the insert as the delete wil have an impact on the rebuild of your index. Using a simple select to check if the row exists and if so perform an update is with large tables far more effectient and is worth benchmarking on small tables]]></content:encoded>
      <pubDate>Thu, 11 May 2006 11:19:42 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #2 on quick MySQL nice-to-know]]></title>
      <link>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-646</link>
      <guid>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-646</guid>
      <description><![CDATA[I knew that REPLACE INTO would do that, but that&#8217;s fine in this case. It&#8217;s only executed when content is updated. And the tables won&#8217;t be that large, maybe a couple of thousand rows at the very very most.<br />
<br />
Also, with REPLACE I get to know the fact if a row was added or replaced, via mysql_affected_rows, which is subsequently either 1 or 2. Only that I have no use for it this time&#8230;<br />
<br />
Is there a difference between REPLACE and REPLACE INTO, it looks like it&#8217;s just a cosmetic thing?<br />
<br />
By the way, Rick, I had to slightly edit your comment, it somehow came out with mixed up lines.]]></description>
      <content:encoded><![CDATA[I knew that REPLACE INTO would do that, but that&#8217;s fine in this case. It&#8217;s only executed when content is updated. And the tables won&#8217;t be that large, maybe a couple of thousand rows at the very very most.<br />
<br />
Also, with REPLACE I get to know the fact if a row was added or replaced, via mysql_affected_rows, which is subsequently either 1 or 2. Only that I have no use for it this time&#8230;<br />
<br />
Is there a difference between REPLACE and REPLACE INTO, it looks like it&#8217;s just a cosmetic thing?<br />
<br />
By the way, Rick, I had to slightly edit your comment, it somehow came out with mixed up lines.]]></content:encoded>
      <pubDate>Thu, 11 May 2006 12:57:50 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #3 on quick MySQL nice-to-know]]></title>
      <link>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-651</link>
      <guid>http://www.contentwithstyle.co.uk/content/quick-mysql-nice-to-know/#comment-651</guid>
      <description><![CDATA[There is no actual difference between REPLACE en REPLACE INTO it is more something the developer decides. You could do a replace into with the syntax of the insert statement or you could do replace with the syntax of the update statement.<br />
<br />
REPLACE INTO someTable (field) VALUEs (value)<br />
REPLACE someTable set field  = value]]></description>
      <content:encoded><![CDATA[There is no actual difference between REPLACE en REPLACE INTO it is more something the developer decides. You could do a replace into with the syntax of the insert statement or you could do replace with the syntax of the update statement.<br />
<br />
REPLACE INTO someTable (field) VALUEs (value)<br />
REPLACE someTable set field  = value]]></content:encoded>
      <pubDate>Fri, 12 May 2006 06:52:27 +0000</pubDate>
    </item>
  </channel>
</rss>
