<?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"
	>
<channel>
	<title>Comments on: Be careful when joining on CONCAT</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/</link>
	<description>Everything about MySQL Performance</description>
	<pubDate>Tue, 02 Dec 2008 18:24:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: techblog.tilllate.com &#187; Peter Zaitsev of the MySQL Performance Blog speaks in Zurich-</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-197105</link>
		<dc:creator>techblog.tilllate.com &#187; Peter Zaitsev of the MySQL Performance Blog speaks in Zurich-</dc:creator>
		<pubDate>Sun, 18 Nov 2007 18:29:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-197105</guid>
		<description>[...] He and his partners of Percona write about topics like eliminating ORDER BY function or Be careful when joining on CONCAT. Peter also held presentations at all Mysql Conferences. In 2007, for example he talked about [...]</description>
		<content:encoded><![CDATA[<p>[...] He and his partners of Percona write about topics like eliminating ORDER BY function or Be careful when joining on CONCAT. Peter also held presentations at all Mysql Conferences. In 2007, for example he talked about [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aurimas</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178108</link>
		<dc:creator>Aurimas</dc:creator>
		<pubDate>Wed, 17 Oct 2007 11:56:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178108</guid>
		<description>Paul,

thanks. Actually, what you mentioned - was my very first recommendation for the customer. Thing is, in this case - there is a number of different tables in place of tb2 joined and in each case - different prefix is used. As query is really executed only occasionally, having it executed in less than a second (instead of few minutes) is enough and it does not cause additional disk/memory waste.

But, I agree- schema should be planned to avoid that sort of join in advance.</description>
		<content:encoded><![CDATA[<p>Paul,</p>
<p>thanks. Actually, what you mentioned - was my very first recommendation for the customer. Thing is, in this case - there is a number of different tables in place of tb2 joined and in each case - different prefix is used. As query is really executed only occasionally, having it executed in less than a second (instead of few minutes) is enough and it does not cause additional disk/memory waste.</p>
<p>But, I agree- schema should be planned to avoid that sort of join in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paul</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178080</link>
		<dc:creator>paul</dc:creator>
		<pubDate>Wed, 17 Oct 2007 10:34:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178080</guid>
		<description>@peter

I understand where your coming from and whilst I don't recommend wrapping crap design with hacks, you could actually eliminate the concat from the select query by adding an additional column to the table and use a trigger which updates this additional column by performing the concat at point of data insert/update.  Then by changing the select query to use our new column we have eliminated the concat on where clause and have got all the speed benefits of a properly designed schema.</description>
		<content:encoded><![CDATA[<p>@peter</p>
<p>I understand where your coming from and whilst I don&#8217;t recommend wrapping crap design with hacks, you could actually eliminate the concat from the select query by adding an additional column to the table and use a trigger which updates this additional column by performing the concat at point of data insert/update.  Then by changing the select query to use our new column we have eliminated the concat on where clause and have got all the speed benefits of a properly designed schema.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178045</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 17 Oct 2007 09:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178045</guid>
		<description>Thanks Daniel,

I wanted to add one more thing about it - generally this choice of  making Number a binary string is counter intuitive to me. 

The number is a string and for numbers it does not matter if it is case sensitive and case insensitive so I'd see CONCAT to simply handle numbers by converting them to the type of other argument. 

Though I do not know may be this more intuitive solution would some ugly side effects.</description>
		<content:encoded><![CDATA[<p>Thanks Daniel,</p>
<p>I wanted to add one more thing about it - generally this choice of  making Number a binary string is counter intuitive to me. </p>
<p>The number is a string and for numbers it does not matter if it is case sensitive and case insensitive so I&#8217;d see CONCAT to simply handle numbers by converting them to the type of other argument. </p>
<p>Though I do not know may be this more intuitive solution would some ugly side effects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178038</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 17 Oct 2007 09:10:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178038</guid>
		<description>Dale, Paul   

This would be the case if we would live in the perfect world.  True  in the database with good design you would not join on CONCAT but there are a lot of databases which are written with not so good design, and these are the ones which we're called to fix quite commonly.


Often to do it right you would need to redo quite a lot, however the customer may not be ready for that in many cases so we end up squeezing as much as we can from the current schema  which brings us to deal with strange queries which bring various weird issues.</description>
		<content:encoded><![CDATA[<p>Dale, Paul   </p>
<p>This would be the case if we would live in the perfect world.  True  in the database with good design you would not join on CONCAT but there are a lot of databases which are written with not so good design, and these are the ones which we&#8217;re called to fix quite commonly.</p>
<p>Often to do it right you would need to redo quite a lot, however the customer may not be ready for that in many cases so we end up squeezing as much as we can from the current schema  which brings us to deal with strange queries which bring various weird issues.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Schneller</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178037</link>
		<dc:creator>Daniel Schneller</dc:creator>
		<pubDate>Wed, 17 Oct 2007 09:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-178037</guid>
		<description>While I generally agree that the schema design is suboptimal if you get into situations like this, sometimes you just cannot help it. Unfortunately(?) we do not live in a perfect world, and existing systems cannot always easily be changed. So it is important to know the caveats that might bite you if you have to do such things.</description>
		<content:encoded><![CDATA[<p>While I generally agree that the schema design is suboptimal if you get into situations like this, sometimes you just cannot help it. Unfortunately(?) we do not live in a perfect world, and existing systems cannot always easily be changed. So it is important to know the caveats that might bite you if you have to do such things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dale</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-177856</link>
		<dc:creator>Dale</dc:creator>
		<pubDate>Wed, 17 Oct 2007 00:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-177856</guid>
		<description>I agree.  I had the same initial thought.  I could not think of a time that I would need to use a concat() within the where clause.  The whole idea behind a good scheme model is that you use good keys that match up without needing further tweaking.</description>
		<content:encoded><![CDATA[<p>I agree.  I had the same initial thought.  I could not think of a time that I would need to use a concat() within the where clause.  The whole idea behind a good scheme model is that you use good keys that match up without needing further tweaking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paul</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-177821</link>
		<dc:creator>paul</dc:creator>
		<pubDate>Tue, 16 Oct 2007 23:24:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/16/be-careful-when-joining-on-concat/#comment-177821</guid>
		<description>I am surprised to see this blog posting, as there is nothing to be careful about joining on concat, simply if you are doing that your DB design is grossly wrong.  Stop and think how ridiculous it is to be concat'ing a string on every query and joining on it.</description>
		<content:encoded><![CDATA[<p>I am surprised to see this blog posting, as there is nothing to be careful about joining on concat, simply if you are doing that your DB design is grossly wrong.  Stop and think how ridiculous it is to be concat&#8217;ing a string on every query and joining on it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
