<?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: MySQL VIEW as performance troublemaker</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/</link>
	<description>Everything about MySQL Performance</description>
	<pubDate>Tue, 02 Dec 2008 12:51:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Dancing Mammoth :: Blog Archive :: Derived Attributes with UNION</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-343175</link>
		<dc:creator>Dancing Mammoth :: Blog Archive :: Derived Attributes with UNION</dc:creator>
		<pubDate>Sun, 10 Aug 2008 16:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-343175</guid>
		<description>[...] MySQL 5.0 or above, you won&#8217;t be able to mitigate this problem by using a VIEW.  MySQL is not very good at optimizing views. If there is not a one-to-one relationship between the rows of your view and the rows of the [...]</description>
		<content:encoded><![CDATA[<p>[...] MySQL 5.0 or above, you won&#8217;t be able to mitigate this problem by using a VIEW.  MySQL is not very good at optimizing views. If there is not a one-to-one relationship between the rows of your view and the rows of the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-327174</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sun, 13 Jul 2008 01:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-327174</guid>
		<description>This post makes it clear that indexes will not be used for views that use temporary tables. For views that do not use temporary tables, will 'joining' or 'whereing' on a column that is indexed in the underlying table use that index?</description>
		<content:encoded><![CDATA[<p>This post makes it clear that indexes will not be used for views that use temporary tables. For views that do not use temporary tables, will &#8216;joining&#8217; or &#8216;whereing&#8217; on a column that is indexed in the underlying table use that index?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bimal Poudel</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-290369</link>
		<dc:creator>Bimal Poudel</dc:creator>
		<pubDate>Wed, 30 Apr 2008 11:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-290369</guid>
		<description>Views meant to hide the complexities in the user's side. This helps you to shorten your query. Optimization is to be done from the MySQL server itself. But have you ever heard of something like indexing a view? Something else? As a developer, performance too matters.</description>
		<content:encoded><![CDATA[<p>Views meant to hide the complexities in the user&#8217;s side. This helps you to shorten your query. Optimization is to be done from the MySQL server itself. But have you ever heard of something like indexing a view? Something else? As a developer, performance too matters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-272644</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 10 Apr 2008 13:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-272644</guid>
		<description>Ascanio and others: Try using Stored Procedure, for this example.

DELIMITER $$
DROP PROCEDURE IF EXISTS `test2`.`user_count` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_count`(param1 int)
BEGIN
SELECT count(*) FROM comments WHERE user_id=param1; 
END $$
DELIMITER ;

Run the above code
then CALL user_count(5);  It will run SELECT count(*) FROM comments WHERE user_id=5; and just as fast as the straight select (from my testing less than 0.001 milisecond difference, sometimes the CALL was faster, but thats just due to random flux you might notice a difference if you were making thousands of calls a second..</description>
		<content:encoded><![CDATA[<p>Ascanio and others: Try using Stored Procedure, for this example.</p>
<p>DELIMITER $$<br />
DROP PROCEDURE IF EXISTS `test2`.`user_count` $$<br />
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_count`(param1 int)<br />
BEGIN<br />
SELECT count(*) FROM comments WHERE user_id=param1;<br />
END $$<br />
DELIMITER ;</p>
<p>Run the above code<br />
then CALL user_count(5);  It will run SELECT count(*) FROM comments WHERE user_id=5; and just as fast as the straight select (from my testing less than 0.001 milisecond difference, sometimes the CALL was faster, but thats just due to random flux you might notice a difference if you were making thousands of calls a second..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-254310</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 19 Mar 2008 03:44:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-254310</guid>
		<description>Not in 5.1 at least.    6.0 have some optimizations which would affect views but I'm not sure if there are general fixes.</description>
		<content:encoded><![CDATA[<p>Not in 5.1 at least.    6.0 have some optimizations which would affect views but I&#8217;m not sure if there are general fixes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-254300</link>
		<dc:creator>Geoff</dc:creator>
		<pubDate>Wed, 19 Mar 2008 03:25:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-254300</guid>
		<description>Have MySQL views improved at all - for any version?</description>
		<content:encoded><![CDATA[<p>Have MySQL views improved at all - for any version?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ascanio</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-240784</link>
		<dc:creator>Ascanio</dc:creator>
		<pubDate>Sat, 09 Feb 2008 20:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-240784</guid>
		<description>I've been working with MySQL Views since release 5 was first made available.
It took me and my team about 2 months of testing to understand that it is just too soon to use Views.

What we did as a solution was to create an extra layer between PHP and MySQL (written in PHP). Hardcoding the complex queries in functions, with our own caching logic. This made it for us, for now.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been working with MySQL Views since release 5 was first made available.<br />
It took me and my team about 2 months of testing to understand that it is just too soon to use Views.</p>
<p>What we did as a solution was to create an extra layer between PHP and MySQL (written in PHP). Hardcoding the complex queries in functions, with our own caching logic. This made it for us, for now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-232653</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Tue, 22 Jan 2008 11:47:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-232653</guid>
		<description>How would you use views to cache queries in MySQL ?

MySQL does not have materialized views so  whenever you access view it will be always reevaluated.</description>
		<content:encoded><![CDATA[<p>How would you use views to cache queries in MySQL ?</p>
<p>MySQL does not have materialized views so  whenever you access view it will be always reevaluated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Serban</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-230320</link>
		<dc:creator>Serban</dc:creator>
		<pubDate>Sat, 12 Jan 2008 10:12:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-230320</guid>
		<description>i see VIEWS like a good alternative to caching some of the queries. Example: you have a site, with a `categories` menu (parent-&#62;childs) that are conditioned to appear in the menu by the number of `products` they reffer to. Every time a user loads a page you load that menu. If you have a large database, you don't want to execute each time that menu (query), so you only SELECT the view. i think this is a primary use of VIEWS besides caching reports that don't contain indexes but full values. please correct me if i'm wrong.</description>
		<content:encoded><![CDATA[<p>i see VIEWS like a good alternative to caching some of the queries. Example: you have a site, with a `categories` menu (parent-&gt;childs) that are conditioned to appear in the menu by the number of `products` they reffer to. Every time a user loads a page you load that menu. If you have a large database, you don&#8217;t want to execute each time that menu (query), so you only SELECT the view. i think this is a primary use of VIEWS besides caching reports that don&#8217;t contain indexes but full values. please correct me if i&#8217;m wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Ford</title>
		<link>http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-199852</link>
		<dc:creator>Bill Ford</dc:creator>
		<pubDate>Tue, 20 Nov 2007 16:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/#comment-199852</guid>
		<description>If I have a view used to join data (via a UNION select) stored in separate tables, then use a where clause when selecting from the view, is that a case where MySQL would be inefficient?  I don't want it to create a temporary table of ALL the data in ALL the tables, I really was hoping for more of a macro-expand kind of thing.</description>
		<content:encoded><![CDATA[<p>If I have a view used to join data (via a UNION select) stored in separate tables, then use a where clause when selecting from the view, is that a case where MySQL would be inefficient?  I don&#8217;t want it to create a temporary table of ALL the data in ALL the tables, I really was hoping for more of a macro-expand kind of thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
