<?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: How to tell when using INFORMATION_SCHEMA might crash your database</title>
	<atom:link href="http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/</link>
	<description>News and views from Pythian DBAs</description>
	<lastBuildDate>Fri, 10 Feb 2012 13:01:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Shlomi Noach</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-605265</link>
		<dc:creator>Shlomi Noach</dc:creator>
		<pubDate>Sun, 02 Oct 2011 13:34:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-605265</guid>
		<description>Hmmmm...
Prematurely jumped to conclusions. When I do:

explain select * from information_schema.statistics where table_schema=&#039;sakila&#039;\G

I DO get &quot;Scanned 1 database&quot;.

Need to be careful about the right schema column!</description>
		<content:encoded><![CDATA[<p>Hmmmm&#8230;<br />
Prematurely jumped to conclusions. When I do:</p>
<p>explain select * from information_schema.statistics where table_schema=&#8217;sakila&#8217;\G</p>
<p>I DO get &#8220;Scanned 1 database&#8221;.</p>
<p>Need to be careful about the right schema column!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shlomi Noach</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-605261</link>
		<dc:creator>Shlomi Noach</dc:creator>
		<pubDate>Sun, 02 Oct 2011 13:31:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-605261</guid>
		<description>Sheeri, great info.
I&#039;m using the comments here to present with the following experience:
SELECTing from TABLES, COLUMNS with a given schema name (i.e. `sakila`), does indeed make for a &quot;Scanned 1 database&quot;.

SELECTing from STATISTICS (indexes table) -- does NOT, sadly:

explain select * from information_schema.statistics where index_schema=&#039;sakila&#039;\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: statistics
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: NULL
        Extra: Using where; Open_full_table; Scanned all databases


Which is strange, since I would put them on the same level.

With REFERENTIAL_CONSTRAINTS or KEY_COLUMN_USAGE, this does not work, as well. Here, I may reason that FK constraints may refer to tables in two different schemata; so this makes more sense.</description>
		<content:encoded><![CDATA[<p>Sheeri, great info.<br />
I&#8217;m using the comments here to present with the following experience:<br />
SELECTing from TABLES, COLUMNS with a given schema name (i.e. `sakila`), does indeed make for a &#8220;Scanned 1 database&#8221;.</p>
<p>SELECTing from STATISTICS (indexes table) &#8212; does NOT, sadly:</p>
<p>explain select * from information_schema.statistics where index_schema=&#8217;sakila&#8217;\G<br />
*************************** 1. row ***************************<br />
           id: 1<br />
  select_type: SIMPLE<br />
        table: statistics<br />
         type: ALL<br />
possible_keys: NULL<br />
          key: NULL<br />
      key_len: NULL<br />
          ref: NULL<br />
         rows: NULL<br />
        Extra: Using where; Open_full_table; Scanned all databases</p>
<p>Which is strange, since I would put them on the same level.</p>
<p>With REFERENTIAL_CONSTRAINTS or KEY_COLUMN_USAGE, this does not work, as well. Here, I may reason that FK constraints may refer to tables in two different schemata; so this makes more sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baron Schwartz</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-407443</link>
		<dc:creator>Baron Schwartz</dc:creator>
		<pubDate>Fri, 19 Feb 2010 14:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-407443</guid>
		<description>For those of us who write tools such as Maatkit that will run on a variety of server versions, the fixes in 5.1 are too little, too late.  INFORMATION_SCHEMA is forever banned for Maatkit.  And the same is true for me as a human -- I will always use SHOW commands.</description>
		<content:encoded><![CDATA[<p>For those of us who write tools such as Maatkit that will run on a variety of server versions, the fixes in 5.1 are too little, too late.  INFORMATION_SCHEMA is forever banned for Maatkit.  And the same is true for me as a human &#8212; I will always use SHOW commands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-406773</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Wed, 17 Feb 2010 14:37:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-406773</guid>
		<description>Mm, some further testing shows that SCHEMA() actually does work, but only if the default database is set:


[code wraplines=&quot;false&quot;]
mysql&gt; select schema();
+----------+
&#124; schema() &#124;
+----------+
&#124; NULL     &#124;
+----------+
1 row in set (0.00 sec)

mysql&gt; explain select * from information_schema.tables where table_schema = schema();
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
&#124; id &#124; select_type &#124; table  &#124; type &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows &#124; Extra                                               &#124;
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
&#124;  1 &#124; SIMPLE      &#124; tables &#124; ALL  &#124; NULL          &#124; NULL &#124; NULL    &#124; NULL &#124; NULL &#124; Using where; Skip_open_table; Scanned all databases &#124;
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
1 row in set (1.95 sec)

mysql&gt; use test;
Database changed
mysql&gt; select schema();
+----------+
&#124; schema() &#124;
+----------+
&#124; test     &#124;
+----------+
1 row in set (0.00 sec)

mysql&gt; explain select * from information_schema.tables where table_schema = schema();
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
&#124; id &#124; select_type &#124; table  &#124; type &#124; possible_keys &#124; key          &#124; key_len &#124; ref  &#124; rows &#124; Extra                                            &#124;
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
&#124;  1 &#124; SIMPLE      &#124; tables &#124; ALL  &#124; NULL          &#124; TABLE_SCHEMA &#124; NULL    &#124; NULL &#124; NULL &#124; Using where; Open_full_table; Scanned 1 database &#124;
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
1 row in set (0.00 sec)
[/code]
</description>
		<content:encoded><![CDATA[<p>Mm, some further testing shows that SCHEMA() actually does work, but only if the default database is set:</p>
<pre class="brush: plain; title: ; wrap-lines: false;">
mysql&gt; select schema();
+----------+
| schema() |
+----------+
| NULL     |
+----------+
1 row in set (0.00 sec)

mysql&gt; explain select * from information_schema.tables where table_schema = schema();
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
| id | select_type | table  | type | possible_keys | key  | key_len | ref  | rows | Extra                                               |
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
|  1 | SIMPLE      | tables | ALL  | NULL          | NULL | NULL    | NULL | NULL | Using where; Skip_open_table; Scanned all databases |
+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------------------------------+
1 row in set (1.95 sec)

mysql&gt; use test;
Database changed
mysql&gt; select schema();
+----------+
| schema() |
+----------+
| test     |
+----------+
1 row in set (0.00 sec)

mysql&gt; explain select * from information_schema.tables where table_schema = schema();
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
| id | select_type | table  | type | possible_keys | key          | key_len | ref  | rows | Extra                                            |
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
|  1 | SIMPLE      | tables | ALL  | NULL          | TABLE_SCHEMA | NULL    | NULL | NULL | Using where; Open_full_table; Scanned 1 database |
+----+-------------+--------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
1 row in set (0.00 sec)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-406715</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Wed, 17 Feb 2010 08:44:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-406715</guid>
		<description>Hi! 

great post - didn&#039;t know this existed. Unfortunately, it seems my favorite trick to restrict results to the current schema, the SCHEMA() function, doesn&#039;t trigger optimization. 

(I mean, SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA = SCHEMA() will scan all dirs, whereas the equivalent using a string constant instead of SCHEMA() only scans one dir)</description>
		<content:encoded><![CDATA[<p>Hi! </p>
<p>great post &#8211; didn&#8217;t know this existed. Unfortunately, it seems my favorite trick to restrict results to the current schema, the SCHEMA() function, doesn&#8217;t trigger optimization. </p>
<p>(I mean, SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA = SCHEMA() will scan all dirs, whereas the equivalent using a string constant instead of SCHEMA() only scans one dir)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Hanlon</title>
		<link>http://www.pythian.com/news/8633/how-to-tell-when-using-information_schema-might-crash-your-database/#comment-406647</link>
		<dc:creator>Tom Hanlon</dc:creator>
		<pubDate>Wed, 17 Feb 2010 01:27:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/news/?p=8633#comment-406647</guid>
		<description>Sheeri, 

Thanks for the information, I never thought to run explain against an information_schema query. 

In class I use queries against information_schema to show issues around opening tables, and the table_open_cache and table_definition_cache. 

Hitting some columns in the information_schema tables open tables, and/or table_definition. 

This option gives me new tools to play with. 

Thanks. 

Now.. if what happens if we profile a query against information_schema.. Does the server crash.. or do we learn something interesting ? Or both ? 

--
Tom Hanlon</description>
		<content:encoded><![CDATA[<p>Sheeri, </p>
<p>Thanks for the information, I never thought to run explain against an information_schema query. </p>
<p>In class I use queries against information_schema to show issues around opening tables, and the table_open_cache and table_definition_cache. </p>
<p>Hitting some columns in the information_schema tables open tables, and/or table_definition. </p>
<p>This option gives me new tools to play with. </p>
<p>Thanks. </p>
<p>Now.. if what happens if we profile a query against information_schema.. Does the server crash.. or do we learn something interesting ? Or both ? </p>
<p>&#8211;<br />
Tom Hanlon</p>
]]></content:encoded>
	</item>
</channel>
</rss>

