<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>redCloverBI</title>
	<atom:link href="http://redcloverbi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://redcloverbi.wordpress.com</link>
	<description>Herramienta de Reporting y Bi en General</description>
	<lastBuildDate>Sun, 11 Dec 2011 16:04:49 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='redcloverbi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>redCloverBI</title>
		<link>http://redcloverbi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://redcloverbi.wordpress.com/osd.xml" title="redCloverBI" />
	<atom:link rel='hub' href='http://redcloverbi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>MySQL</title>
		<link>http://redcloverbi.wordpress.com/2011/12/02/mysql/</link>
		<comments>http://redcloverbi.wordpress.com/2011/12/02/mysql/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 16:23:03 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Tecnologias]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[openSource]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=577</guid>
		<description><![CDATA[Buenos días, Adjunto a este post esta una charla sobre optimización de MySQL tanto la presentación como el vídeo. Tambien adjunto una presentacion que se comente en la primera sobre particiones de MySQL  que siempre se nos pasan. Optimización del rendimiento con MySQL<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=577&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Buenos días,</p>
<p>Adjunto a este post esta una charla sobre optimización de MySQL tanto la presentación como el <a href="http://www.youtube.com/watch?gl=ES&amp;v=_-fMNjebEX0">vídeo</a>.</p>
<p>Tambien adjunto una presentacion que se comente en la primera sobre particiones de MySQL  que siempre se nos pasan.</p>
<!--YouTube Error: bad URL entered-->
<div id="__ss_10101938" style="width:425px;">
<p><strong><a title="Optimización del rendimiento con MySQL" href="http://www.slideshare.net/capitangolo/optimizacin-del-rendimiento-con-mysql" target="_blank">Optimización del rendimiento con MySQL</a></strong> <iframe src='http://www.slideshare.net/slideshow/embed_code/10101938' width='425' height='348' scrolling='no'></iframe></p>
<iframe src='http://www.slideshare.net/slideshow/embed_code/5235422' width='540' height='443'></iframe>
<div style="padding:5px 0 12px;"></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/577/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=577&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/12/02/mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>
	</item>
		<item>
		<title>Camino de ida y vuelta</title>
		<link>http://redcloverbi.wordpress.com/2011/10/29/camino-de-ida-y-vuelta/</link>
		<comments>http://redcloverbi.wordpress.com/2011/10/29/camino-de-ida-y-vuelta/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 19:30:22 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[openSource]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=573</guid>
		<description><![CDATA[Buenas a todos, hace ya mucho que no hago un post, no es por falta de ganas ni por falta de temas, sino por tiempo.Pero ahi va. Desde hace tiempo en Pentaho hay una bicefalia , es decir, entre la CE y la EE, empieza haber cambios grandes , ¿por que?, pues la respuesta es facil Pentaho [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=573&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Buenas a todos,</p>
<p style="text-align:justify;">hace ya mucho que no hago un post, no es por falta de ganas ni por falta de temas, sino por tiempo.Pero ahi va.</p>
<p style="text-align:justify;">Desde hace tiempo en Pentaho hay una bicefalia , es decir, entre la CE y la EE, empieza haber cambios grandes , ¿por que?, pues la respuesta es facil Pentaho no le interesa la CE. La semana pasada hable con un par de partners de Pentaho uno Español y otro de UK  y me confirmaron las sospechas , el nuevo CEO tiene la inatencion de cerrar Pentaho y pasar a un modelo mas cerrado por eso los avances van siempre a la EE. Lo unico que falta segun me conetaron es convencer a Julian que ha sido el mas reticente a este cambio pero a la larga Pentaho sera cerrado.</p>
<p style="text-align:justify;">Como nos va a afectar a los que usamos y desarrollamos para la CE pues la verdad no estoy muy seguro pero nos va a perjudicar, eso seguro. El abandono por parte de Pentaho de la version CE tiene su maxima expresion en PEntaho4. El cambio a mejor , todo hay que decirlo tiene cosas que son muy inetresantes y que se reclamava hace mucho tiempo como:</p>
<ol>
<li>Parametrizar vistas de manera fácil</li>
<li>Rankis  en las vistas</li>
<li>Roles de Mondrian</li>
<li>etc&#8230;</li>
</ol>
<div><!--YouTube Error: bad URL entered--></div>
<p style="text-align:justify;">pero el cambio mas fuerte no han sido esos sino el enfoque sobre el agil BI y hadoop que solo se puede ver en la version de pago.</p>
<p style="text-align:justify;">A todo esto la verdad el CEO Quentin Gallivan , no se si va a luchar por el modelo cerrado pero el que se quede al mando de la version CE tiene que empezar a pensar en el futuro de esta linea quizá un cambio en el modelo de negocio seria lo suyo y centrase en el mundo del Bi hacia las NOSql y la nube.</p>
<p style="text-align:justify;">Solo el tiempo lo sabre pero esto es un camino de ida y vuelta pero¿ Pentaho es Bi open Source?</p>
<p style="text-align:justify;">Opiniones.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/573/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=573&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/10/29/camino-de-ida-y-vuelta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>
	</item>
		<item>
		<title>RoR que es ? Entrevista Casual a Raul Murciano</title>
		<link>http://redcloverbi.wordpress.com/2011/06/12/ror-que-es-entrevista-casual-a-raul-murciano/</link>
		<comments>http://redcloverbi.wordpress.com/2011/06/12/ror-que-es-entrevista-casual-a-raul-murciano/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 19:13:56 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[Tecnologias]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=564</guid>
		<description><![CDATA[Desde hace un tiempo vengo intentado en cada proyecto que voy introducir RoR en los cuadros de mando y cosas similar , mi gran problema es el desconocimiento de la tecnología y sobre todo Java. He pedido a un amigo que además es una estrella sobre el tema  una mini entrevista con algunas preguntas sobre [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=564&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Desde hace un tiempo vengo intentado en cada proyecto que voy introducir RoR en los cuadros de mando y cosas similar , mi gran problema es el desconocimiento de la tecnología y sobre todo Java.</p>
<p style="text-align:justify;">He pedido a un amigo que además es una estrella sobre el tema  una mini entrevista con algunas preguntas sobre RoR , no es para iniciarse pero si para que les pique el gusanillo y se indague mas .</p>
<p style="text-align:justify;">Como no soy  un experto  he pedido ayuda a gente que si lo son así que si ven alguna cosa que no cuadre o no les guste ya sabes comentario.</p>
<p style="text-align:justify;">¿Que es RoR [1]?</p>
<p style="text-align:justify;"><strong>Ruby on Rails</strong>, también conocido como <strong>RoR</strong> o <strong>Rails</strong> es un <a title="Framework" href="http://es.wikipedia.org/wiki/Framework">framework</a> de <a title="Aplicación web" href="http://es.wikipedia.org/wiki/Aplicaci%C3%B3n_web">aplicaciones web</a> de <a title="Código abierto" href="http://es.wikipedia.org/wiki/C%C3%B3digo_abierto">código abierto</a> escrito en el lenguaje de programación <a title="Ruby" href="http://es.wikipedia.org/wiki/Ruby">Ruby</a>, siguiendo el paradigma de la arquitectura <a title="Modelo Vista Controlador" href="http://es.wikipedia.org/wiki/Modelo_Vista_Controlador">Modelo Vista Controlador</a> (MVC). Trata de combinar la simplicidad con la posibilidad de desarrollar aplicaciones del mundo real escribiendo menos código que con otros frameworks y con un mínimo de configuración. El lenguaje de programación Ruby permite la <a title="Metaprogramación" href="http://es.wikipedia.org/wiki/Metaprogramaci%C3%B3n">metaprogramación</a>, de la cual Rails hace uso, lo que resulta en una sintaxis que muchos de sus usuarios encuentran muy legible. Rails se distribuye a través de <a title="RubyGems" href="http://es.wikipedia.org/wiki/RubyGems">RubyGems</a>, que es el formato oficial de paquete y canal de distribución de bibliotecas y aplicaciones Ruby.</p>
<p style="text-align:justify;">Ahoa que tenemos mas o menos una ida muy muy muy &#8230;. muy basica de lo que es  vamos con la entrevista:</p>
<p style="text-align:justify;"><a href="http://redcloverbi.files.wordpress.com/2011/06/baneer.png"><img class="size-full wp-image-565 alignleft" title="baneer" src="http://redcloverbi.files.wordpress.com/2011/06/baneer.png?w=540" alt=""   /></a></p>
<ul>
<li>¿Como esta el RoR en San Francisco (SF)?</li>
</ul>
<p style="text-align:justify;">Pues la verdad es que en plena forma. En SF hay muchísimas start-ups y muchas de ellas basan su tecnología en la web. Rails encaja muy bien con la filosofía de una start-up: permite prototipar muy rápido sin que el código deje de ser mantenible, ir refinando el prototipo mediante iteraciones cortas, incorporar gente al equipo es fácil porque todo el mundo sigue las mismas convenciones&#8230; Aquí se han dado cuenta de todas estas ventajas y, pese a que hay una cantidad tremenda de empresas&#8230; siguen haciendo falta programadores!</p>
<ul style="text-align:justify;">
<li>¿Como te has adaptado a SF?</li>
</ul>
<p style="text-align:justify;">SF es una ciudad muy acogedora, siempre encuentras alguien dispuesto a orientarte o echarte un cable. Tengo la sensación de que muchos de sus habitantes también proceden de otros sitios y hay cierto ambiente de solidaridad.</p>
<p style="text-align:justify;">Eso sí, es una ciudad muy cara, especialmente el tema del alojamiento está por las nubes. En nuestro caso hemos optado por vivir en las afueras, en Berkeley: en 20 minutos de BART (parecido al metro) estamos en la ciudad y es un sitio más pequeño que encaja muy bien con nuestro estilo de vida (venimos de vivir en un pueblecito de la Costa Brava). Nos gusta tener la ciudad cerca para hacer alguna escapada de vez en cuando, pero para el día a día preferimos un sitio más tranquilo&#8230; será que nos hacemos mayores <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p style="text-align:justify;">El idioma es sin duda mi punto débil, pero es parte de lo que quiero mejorar durante el tiempo que esté aquí. Por suerte mis compañeros de trabajo son encantadores y tienen una paciencia tremenda conmigo.</p>
<p style="text-align:justify;">Lo que no podemos evitar es echar de menos a la familia: por suerte podemos hablamos por videoconferencia muy a menudo y les mantenemos informados por facebook para compartir con ellos un poco de nuestro día a día. Tener la familia y los amigos lejos es sin duda lo que más nos cuesta de estar aquí.</p>
<ul style="text-align:justify;">
<li>¿Como ves Ruby y RoR desde un punto de vista tan privilegiado como heroku?</li>
</ul>
<p style="text-align:justify;">Heroku aloja miles de aplicaciones basadas en Rails y en ese sentido  sí es un punto de vista privilegiado porque puedes ver cómo aumenta el número de empresas que apuestan por Rails. Nuestro equipo de ventas nos informa cuando detecta alguna empresa conocida adopta nuestra plataforma y por suerte ocurre bastante a menudo. Por otra parte, Heroku utiliza internamente muchísimos proyectos open source desarrollados en Ruby. En todos ellos ves que la evolución no para y que tienen un ritmo de actividad impresionante, igual que impresiona el número de grupos locales y de conferencias dedicadas a practicar y difundir las bondades de Ruby y Ruby on Rails por todo el mundo. Por todo esto creo que tanto a nivel de popularidad entre las empresas<br />
como de actividad por parte de la comunidad Ruby y Ruby on Rails están en un momento dulce.</p>
<ul style="text-align:justify;">
<li>Que crees que le falta a RoR para difundirse mas?</li>
</ul>
<p style="text-align:justify;">Tiempo. Creo que en las tecnologías, como en muchas áreas de conocimiento,cada persona tiene distintos grados de interés y de<br />
permeabilidad hacia las novedades. Diría que tanto Ruby en el campo de la programación como Rails en el del desarrollo web han hecho suficiente &#8220;ruido&#8221; como para que la gente que tiene interés en estar al día haya oído hablar de ellos.<br />
También creo que esa entre esa gente se ha creado suficiente masa crítica de usuarios como para darle entrada en el mundo empresarial, y que las empresas que tienen interés y se lo pueden permitir han empezado a probar Ruby y Rails con pequeños proyectos. Creo que es importante hacer esta puntualización sobre &#8220;las empresas que se lo pueden permitir&#8221; porque hay empresas que, o bien porque se dedican a temas en los que Ruby y Rails no encajan, o tienen una estructura demasiado rígida que les impide evaluar nuevas tecnologías (lo cual me parece peligroso a largo plazo si la tecnología juega un papel importante en su negocio).<br />
El siguiente nivel de &#8220;permeabilidad&#8221; serían las personas y empresas que sólo prueban y aprender nuevas tecnologías cuando no les queda más remedio, porque el mercado se lo exige. Ese paso es con diferencia el  más lento y sólo el tiempo dirá si Ruby y Rails llegan a penetrar a ese nivel, pero eso depende en gran medida de otros factores diferentes a la difusión.</p>
<ul style="text-align:justify;">
<li>¿Que crees que le falta a ruby o RoR o en que podía mejorar?</li>
</ul>
<p style="text-align:justify;">Antes de nada me gustaría resaltar que Ruby no es el lenguaje perfecto ni Ruby on Rails el framework ideal para desarrollo web porque &#8220;there are no silver bullets&#8221;.<br />
Vamos con Ruby:<br />
- a nivel de sintaxis es un lenguaje muy conciso pero me gustaría que lo fuera un poco más (por ejemplo soy fan de la tabulación de python vs el &#8220;end&#8221;).<br />
- del desarrollo del lenguaje en sí apenas conozco nada así que poco puedo aportar. Si acaso comentaría que en alguna de las listas<br />
oficiales (ruby-dev) aún se utiliza japonés y yo unificaría en todas el uso del inglés.<br />
- en cuanto a las librerías creo que rubyems, pese a ser un proyecto indispensable para cualquier programador Ruby, aún está a mucha distancia por ejemplo del CPAN de Perl.<br />
- para terminar, siempre le pediremos a ruby más rendimiento y menos consumo de recursos: por suerte hay gente muy buena trabajando en las diferentes implementaciones de Ruby así que veremos mejoras.</p>
<p>En cuanto a Rails:<br />
- la versión 3 ha traído una fuerte reestructuración interna: ahora Rails es mucho más hackeable pero creo que el rendimiento (al menos en modo desarrollo) se ha resentido mucho, así que me gustará ver si mejora en ese aspecto.<br />
- la documentación, tanto a nivel de API como de tutoriales y guías de buenas prácticas, es fundamental para facilitar la adopción y uso de un framework. Por suerte gente como Xavier Noria han dado un paso al frente y con un trabajo diario han conseguido generar una documentación magnífica además de facilitar la participación de cualquier interesado en corregirla o completarla, espero que más gente se anime a colaborar en este apartado.<br />
- como twitteaba hace poco @mgnoriega, es bueno ver que tras una etapa de consolidación Rails está de nuevo innovando: me gustará ver en funcionamiento la gestión automática de assets y su integración con coffeescript en su siguiente versión. Era algo que hasta ahora se gestionaba con plugins: espero que siendo los nuevos defaults su adopción crezca entre los desarrolladores, muchos usuarios se verán beneficiados al visitar webs con contenidos comprimidos y optimizados para su descarga y cacheo.</p>
<ul style="text-align:justify;">
<li>¿Quizá uno de los aportes de RoR sea la metaprogramacion aplicada?</li>
</ul>
<p style="text-align:justify;">Sí y no. Yo creo que la metaprogramación es buena cuando sirve para evitar repetir código, pero creo que en algunas versiones anteriores de Rails se llegó a abusar demasiado de ella: algunos fragmentos eran demasiado &#8220;exóticos&#8221; y eso dificultaba corregir errores o simplemente comprender cómo funcionaban. Creo que hay que buscar un compromiso entre la elegancia y la legibilidad del código y creo que en ese sentido Rails ha madurado bastante.</p>
<ul style="text-align:justify;">
<li>¿Que ventajas ves a ROR frente a PHP y al todo poderoso JAVA?</li>
</ul>
<p style="text-align:justify;">La primera ventaja que yo veo es la sintaxis: creo que Ruby es un lenguaje muchísimo más conciso y elegante que PHP y Java. Hay gente que no le da importancia a estas cosas, pero a mí me parece fundamental que el código sea siempre fácil y rápido de leer, mantener y modificar. En ese sentido creo que Ruby es mejor que PHP (cuya sintaxis para trabajar con orientación a objetos siempre me ha parecido un apaño) y que Java (que en mi opinión tiene una sintaxis que conduce a diseños demasiado recargados).</p>
<p>Para mí, hasta hace poco tiempo PHP era una alternativa válida frente a Rails cuando necesitabas desarrollar una web muy sencilla. Con la aparición de rack y Sinatra no encuentro un ejemplo en el que optar por PHP. Otra ventaja que tenía PHP era su ubicuidad y su facilidad de despliegue: con Heroku tardas menos de un minuto en crear y pasar a producción una aplicación Ruby&#8230; Así que yo ya no le veo ninguna ventaja a PHP.</p>
<p>Java tiene un mercado empresarial grandísimo en varias plataformas diferentes y por tanto hay mucho dinero invertido, no se dejará de utilizar de la noche a la mañana y seguro que mantiene una posición privilegiada en mercados concretos. Eso sí, creo la desaparición de Sun supone un revés muy importante, y no sé si Oracle tiene muy claro qué hacer con lo que ha comprado&#8230; Diría que Java es como los abuelos cascarrabias de las películas: le queda mucho tiempo entre nosotros pero cada vez menos gente quiere hacerse cargo de él.  Como anécdota, Jonathan Schwartz (ex CEO de Sun) utiliza Rails en la empresa que fundó tras vender Sun, y no creo que le falten contactos ni recursos para contratar profesionales Java de primer nivel <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<ul style="text-align:justify;">
<li>Cómo evitar que ROR crezca hasta hacerse inmantenible como JAVA?  ¿Está RoR hecho para el mundo Enterprise?<br />
Las aplicaciones de mi empresa tienen muchos usuarios&#8230; ¿Rails escala?  ¿Crees que hay mundo después de java?</li>
</ul>
<p style="text-align:justify;"><strong>(Agrupo estas tres preguntas para darles una respuesta común).</strong><br />
Creo que con la tecnología que tenemos hoy en día, los culpables de que un proyecto sea difícil de mantener somos las personas y no los lenguajes o frameworks que utilicemos. Los plazos de entrega irreales y la desgana a la hora de programar pueden darse tanto en proyectos Rails como en proyectos Java. Sí creo, como te decía antes, que creo que Ruby ayuda a tener un código más mantenible que Java&#8230; pero durante mi tiempo de freelance he visto aplicaciones Rails cuyo mantenimiento debe ser un infierno, así que usar ruby no asegura nada.<br />
En el 2008, <a href="http://yellowpages.com/" target="_blank">yellowpages.com</a> explicaba en conferencias cómo había migrado de Java a Ruby on Rails. El código pasó de 125.000 a 20.000 líneas, se alegraron de comprobar que había mejorado muchísimo su mantenibilidad y seguían sirviendo más de mil millones de páginas al mes. Como ejemplo extremo de escalabilidad tenemos empresas como twitter o facebook que han probado distintas tecnologías y han terminado ajustándolas a medida para que se adapten a lo que necesitan. El límite de Rails parece que está entre ambos ejemplos pero lo desconozco porque no he trabajado en proyectos de esa escala.</p>
<ul style="text-align:justify;">
<li>Ya tenemos muchos programadores formados&#8230; ¿Compensaría fórmalos en RoR?</li>
</ul>
<p style="text-align:justify;">Yo lo haría si fuera mi empresa y pudiera permitírmelo. Como mínimo, aunque no quieras cambiar de tecnología, seguro que sacarían algunos patrones interesantes que poder aplicar con la tecnología que utilizan actualmente.</p>
<ul style="text-align:justify;">
<li>¿Serían nuestros programadores más felices trabajando con RoR?</li>
</ul>
<p style="text-align:justify;">No lo sé, puedo decirte que yo sí lo soy (he trabajado previamente con PHP y Java).</p>
<p style="text-align:justify;">[1] wikipedia.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/564/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/564/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/564/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=564&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/06/12/ror-que-es-entrevista-casual-a-raul-murciano/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>

		<media:content url="http://redcloverbi.files.wordpress.com/2011/06/baneer.png" medium="image">
			<media:title type="html">baneer</media:title>
		</media:content>
	</item>
		<item>
		<title>Futuro CE vs Presente EE guerra de Visores</title>
		<link>http://redcloverbi.wordpress.com/2011/04/28/futuro-ce-vs-presente-ee-guerra-de-visores/</link>
		<comments>http://redcloverbi.wordpress.com/2011/04/28/futuro-ce-vs-presente-ee-guerra-de-visores/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 19:57:30 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[openSource]]></category>
		<category><![CDATA[Tecnologias]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=520</guid>
		<description><![CDATA[Últimamente está muy en boca de todos los que seguimos en cierta medida el mundo BI el cambio/lavado de cara de el visor OLAP de Pentaho que era muy rivaival de los 70. El visor OLAP que usa Pentaho es JPIVOT tanto en la CC como en la EE y aunque era muy estable, ya [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=520&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><tt><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">Últimamente está muy en boca de todos los que seguimos en cierta medida el mundo BI el cambio/lavado de cara de el visor OLAP </span></span></span></tt><tt><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">de Pentaho</span></span></span></tt><tt><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;"> que era muy rivaival de los 70.</span></span></span></tt></p>
<p style="text-align:justify;"><img class="alignleft" title="SaIK" src="http://www.analytical-labs.com/images/logo.png" alt="" width="200" height="34" /></p>
<p style="text-align:justify;"><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">El visor OLAP que usa Pentaho es JPIVOT tanto en la CC como en la EE y aunque era muy estable, ya que lleva casi 10 años sin apenas cambiar, solo algunos parches para los bug, se hacía neces</span></span></span><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">ario un nuevo visor, se han hecho muchos intentos pero no ha había cuajado ninguno, de hecho hice una lista de algunos hace ya algún tiempo en una serie de post que </span></span></span><span class="Apple-style-span" style="font-family:'DejaVu Sans', sans-serif;font-size:x-small;"> se llamaba ¿Cuál..?.</span></p>
<p style="text-align:justify;"><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">Ahora aparece Saiku que par</span></span></span><span class="Apple-style-span" style="font-family:'DejaVu Sans', sans-serif;font-size:x-small;">a mí es una pasada muy rudimentario pero bueno y lo espero como lluvia de mayo que saquen la GA , cosa que tardara y no se si llegara ,aunque ya he empezado a usarlo en mi particular I+D tiene grandes deficiencias pero para la gente que lo realiza y el precio es una cosa maravillosa.</span></p>
<p style="text-align:justify;"><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">Pero mi pregunta es Pentaho donde ha estado en este tiempo, pues comprado un visor muy chulo e intuitivo pero solo para la EE  aunque se suponía que seria para todos.<a href="http://julianhyde.blogspot.com/2009/10/pentaho-analyzer.html)">link</a> pero al final la política se ha impuesto a &#8216;SU&#8217; modelo de negocio, que para mi, a futuro se ira poco a poco a la quiebra y se lo ha llevado a la EE. Lo que quiero decir es que el tiempo y el dinero se podía haber invertido en crear un visor con la ayuda de OLP4J y de Julian Hyde y que fuera Open Source respetando su movimiento original.</span></span></span></p>
<p style="text-align:justify;"><span style="color:#000000;"><span style="font-family:'DejaVu Sans', sans-serif;"><span style="font-size:x-small;">Como ya comente hace tiempo, Pentaho esta dando mas alas a la versión EE y quitando posibilidades a la versión CE, cosa que no se por que lo hace,si Pentaho esta donde esta es por ser open source y por que tiene ciertas garantias, pero parece que Pentaho ahora necesita mas cosas entre ellas que la version EE se consolide. </span></span></span><span class="Apple-style-span" style="font-family:'DejaVu Sans', sans-serif;font-size:x-small;">Con lo que al final todo será Saiku vs Pentaho Analysis. Y tu ¿Qué crees?</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/520/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=520&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/04/28/futuro-ce-vs-presente-ee-guerra-de-visores/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>

		<media:content url="http://www.analytical-labs.com/images/logo.png" medium="image">
			<media:title type="html">SaIK</media:title>
		</media:content>
	</item>
		<item>
		<title>Optimizar Tiempo de respuesta MYSQL</title>
		<link>http://redcloverbi.wordpress.com/2011/04/28/optimizar-tiempo-de-respuesta-mysql/</link>
		<comments>http://redcloverbi.wordpress.com/2011/04/28/optimizar-tiempo-de-respuesta-mysql/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 14:40:12 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[Tecnologias]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tecnologia]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=523</guid>
		<description><![CDATA[1.- Desavilitar la busqueda por DNS Después de buscar la razón por que la sconsultas me iban muy lentas , vi que el servidor mysql estaba haciendo un montón de consultas haciendo la resolución  por el nombre. ¿Para qué? ¿Por qué esa máquina a una resolución de nombres que sólo las máquinas de la red [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=523&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>1.- Desavilitar la busqueda por DNS</strong></p>
<p>Después de buscar la razón por que la sconsultas me iban muy lentas , vi que el servidor mysql estaba haciendo un montón de consultas haciendo la resolución  por el nombre. ¿Para qué? ¿Por qué esa máquina a una resolución de nombres que sólo las máquinas de la red local se conectan a él.</p>
<p>Para ello vamos a el fichero de configuración <strong>/etc/mysql/my.cnf</strong> ,Para aplicar la opción &#8211; skip-name-resolve interruptor cuando arranca mysqld, sólo tiene que añadir:</p>
<address><strong><em>[mysqld]</em></strong><br />
<strong><em> &#8230;..</em></strong><br />
<strong><em> &#8230;&#8230;</em></strong></address>
<address><strong><em>skip-name-resolve</em></strong></address>
<p><strong>2.- Activar Query Cache.</strong></p>
<p>Después de resolver ese problema, empezamos a ver la carga del servidor  que  cada vez era  mayor, el tiempo de respuesta fue bueno después del cambio anterior, pero ahora, tuvimos que aligerar un poco la carga del servidor.<strong></strong><strong></strong></p>
<ol>
<li>mysql&gt; SHOW STATUS LIKE &#8216;Qcache%&#8217;; Una vez que tenemos cuanta es la memoria cache que necesitamos</li>
<li>mysql&gt; SHOW VARIABLES LIKE &#8216;%query_cache%&#8217;;</li>
</ol>
<p>Se necesita ta tener el  caché de consultas en el primer lugar habilitado (have_query_cache | yes) y asegúrese de que query_cache_type está ajustado en ON. Esto suele estar  activado por defecto en la mayoría de distribuciones de Linux.</p>
<ol>
<li>mysql&gt; SET GLOBAL query_cache_size = 52428800; Le damos la cantidad de cache que queramos.</li>
</ol>
<p>Y solo faltaría restart el servidor</p>
<p><strong>[1]</strong><a href="http://www.debuntu.org/2006/07/21/75-how-to-optimize-mysql-response-time/">Link del articulo original</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/523/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=523&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/04/28/optimizar-tiempo-de-respuesta-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8216;Others&#8217; google chart using the CDF</title>
		<link>http://redcloverbi.wordpress.com/2011/02/13/others-google-chart-using-the-cdf/</link>
		<comments>http://redcloverbi.wordpress.com/2011/02/13/others-google-chart-using-the-cdf/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 18:42:41 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[CDF]]></category>
		<category><![CDATA[openSource]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=512</guid>
		<description><![CDATA[Hi all, this is my first post in English . i try to write  well , but i don&#8217;t know if I&#8217;ll get this . Well, this is a problem, when do you use the google chart in the Dashboard ,generation with the CDF , normal if the valor is too low , don&#8217;t show [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=512&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi all, this is my first post in English <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . i try to write  well , but i don&#8217;t know if I&#8217;ll get this <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Well, this is a problem, when do you use the google chart in the Dashboard ,generation with the CDF , normal if the valor is too low , don&#8217;t show , and the legend put &#8216;Other&#8217; in color gray.</p>
<p>if you like ,you can  show them  all values, if  you add  this parameter ,  sliceVisibilityThreshold:0</p>
<p><pre class="brush: jscript;">chart.draw(data, {legend:'right', legendFontSize:9, width:550, height: 275, is3D: true,sliceVisibilityThreshold:0, title:'titules'});</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/512/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=512&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2011/02/13/others-google-chart-using-the-cdf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>
	</item>
		<item>
		<title>Documentar una ETL</title>
		<link>http://redcloverbi.wordpress.com/2010/10/24/documentar-una-etl/</link>
		<comments>http://redcloverbi.wordpress.com/2010/10/24/documentar-una-etl/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 10:31:04 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[kettle]]></category>
		<category><![CDATA[openSource]]></category>
		<category><![CDATA[PDI]]></category>
		<category><![CDATA[Tecnologias]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=499</guid>
		<description><![CDATA[Una de las cosas mas importantes que hay en un proceso de BI son las ETL que en proporción de un proyecto BI cuestan alrededor de un 60% del tiempo no solo el hecho de conocer el negocio sino comprobar que no hay bucles,o silos de información , etc&#8230;. Una de las cosas que mas me enfada es cuando [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=499&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Una de las cosas mas importantes que hay en un proceso de BI son las ETL que en proporción de un proyecto BI cuestan alrededor de un 60% del tiempo no solo el hecho de conocer el negocio sino comprobar que no hay bucles,o silos de información , etc&#8230;.</p>
<p style="text-align:justify;">Una de las cosas que mas me enfada es cuando tienes la ETL terminada y las ejecutar y el cliente no ve la dificulta de todo el proceso pero claro es normal, la otra es cuando me dicen ¿Donde esta documentación? y claro tu te quedas un poco  O_o pues ahora ya tenemos la solución a ese problema.</p>
<p style="text-align:justify;"><a href="/p/kettle-cookbook/">kettle-cookbook</a></p>
<p style="text-align:justify;">Esta ETL recorre nuestra ETL generando una documentación  sobre los trabajos en formato HTML para que así podamos navegar por ella de manera mas comoda,</p>
<p><img class="alignleft" title="ETL" src="http://kettle-cookbook.googlecode.com/svn-history/r45/trunk/images/kettle-cookbook.PNG" alt="" width="386" height="382" /></p>
<p style="text-align:left;">Realmente útil y fácil de usar invocas el scritp y le pasas el directorio donde está tu ETL y el directorio donde quieres que te deje la documentación ahi dejo las cosas creo que se podrai hacer un script mas complejo y pasar le ese  script  o incluso un paso para asi poder  hacerlo todo de manera mas automatica</p>
<p style="text-align:left;">&nbsp;</p>
<p><pre class="brush: css;">
kitchen.bat -file:kettle-cookbook/pdi/document-all.kjb -param:”INPUT_DIR”=${ruta a la ETL} -param:”OUTPUT_DIR”=${ruta a la documentación  de la ETL}
</pre></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align:left;"><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/499/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=499&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2010/10/24/documentar-una-etl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>

		<media:content url="http://kettle-cookbook.googlecode.com/svn-history/r45/trunk/images/kettle-cookbook.PNG" medium="image">
			<media:title type="html">ETL</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtualizar Servidores</title>
		<link>http://redcloverbi.wordpress.com/2010/10/23/virtualizar-servidores/</link>
		<comments>http://redcloverbi.wordpress.com/2010/10/23/virtualizar-servidores/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 18:28:49 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[Tecnologias]]></category>
		<category><![CDATA[openSource]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=494</guid>
		<description><![CDATA[Bueno como la otra entrada anterior, voy a exponer últimamente , todo el mundo anda virtualizando  como el intento de ahorro/coste , es decir, si tenemos menos maquinas  y las virtualizamos podemos  tener mas maquinas un similares características, en el mercado hay  muchas : Xen Kvm Vbox Wmware Como yo me enfoco mas en el [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=494&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Bueno como la otra entrada anterior, voy a exponer últimamente , todo el mundo anda virtualizando  como el intento de ahorro/coste , es decir, si tenemos menos maquinas  y las virtualizamos podemos  tener mas maquinas un similares características, en el mercado hay  muchas :</p>
<ul style="text-align:justify;">
<li>Xen</li>
<li>Kvm</li>
<li>Vbox</li>
<li>Wmware</li>
</ul>
<p style="text-align:justify;">Como yo me enfoco mas en el software libre   pues he tirado mas por Vbox pero para ponerlo en producción no es una buena idea, ahora y gracias  a un buen amigo luiX_ (http://begnu.wordpress.com/) he empezado a pensar en usar Xen por que  se supone que es la mas estable y permite varias cosas interesantes como pasar maquinas en caliente, pero antes de nada que es Xen googleando un poco he encontrado un post muy interesante [1].</p>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;"><img class="alignleft" title="Xen" src="http://www.glatelier.org/wp-content/uploads/2010/07/xen_logo.gif" alt="" width="149" height="67" />Xen es un hipervisor que soporta x86, x86_64, Itanium, arquitecturas ARM y puede correr GNU/Linux, Windows, Solaris y algunos BSDs como <em>guests</em> (huéspedes). Está apoyada por varias compañías, principalmente por <a href="http://www.citrix.com/xenserver">Citrix</a>, pero también utilizada por <a href="http://wiki.oracle.com/page/Oracle+VM">Oracle</a> para la Oracle VM y otras. Xen puede otorgar una <strong>virtualización completa</strong> en sistemas que permitan extensiones de virtualización, pero también puede funcionar como hipervisor en máquinas que carezcan de ellos.</p>
<p style="text-align:justify;">Al igual que Xen, KVM es el hipervisor del kernel de Linux, por lo tanto el <em>host</em> <strong>tiene</strong> que ser Linux, pero <a href="http://www.linux-kvm.org/page/Guest_Support_Status">puede tener</a> de <em>guests</em> a Linux, Windows, Solaris y BSD. Corre en sistemas con hardware x86 y x86_64 que <strong>cuente con extensiones de virtualización</strong>. Esto significa por tanto, que KVM <strong>no</strong> es la opción para viejas CPUs que fueron construidas antes de que las extensiones fueran desarrolladas, ni tampoco es útil para las nuevas (como las CPUs Intel Atom) que no cuentan con dichas extensiones. En general , no es un problema para los <em>data centers</em> que tienden a reemplazar el hardware cada pocos años — pero significa que KVM no es una opción para algunos nichos <a href="http://www.linux.com/news/enterprise/cloud-computing/323061-lets-get-small-linux-enables-low-power-space-saving-systems">como el SM10000</a> que están intentando utilizar CPUs Atom.</p>
<p style="text-align:justify;">Si quieres corres un host Xen, necesitas <a href="http://wiki.xensource.com/xenwiki/XenDom0Kernels">contar con un kernel soportado</a>. Linux, <strong>no viene</strong> con soporte para correr un host Xen <em>out-of-the-box</em>, aunque algunas distribuciones se han estado lanzando con <a href="http://wiki.xensource.com/xenwiki/Kernel.org_Linux_on_Xen">soporte para correr nativamente como guest</a> desde la versión 2.6.23 (Arch, por ejemplo, cuenta con ellos en el AUR) y algo similar ocurre con Ubuntu (y deduzco también que con Debian y las demás distribuciones). Esto significa que no utilizas una distro común de Linux para correr <em>guests</em> Xen. En cambio, necesitas una distro que venga con soporte para Xen o compilar tu propio kernel. Lo otro, es utilizar alguna solución comercial basada en Xen como <a href="http://www.citrix.be/English/ps2/products/product.asp?contentID=683148&amp;ntref=footer">Citrix XenServer</a>, esto por supuesto presenta el problema que muchas de estas soluciones no son completamente libres.</p>
<p style="text-align:justify;">Recomiendo el uso de esta maquina , es un poco mas compleja que wmware que es la reina del mercado pero una vez que pasas el escalón es de una calidad asombrosa.</p>
<p style="text-align:justify;">Buscando un poco por ahí he encontrado  una utilidad para las maquinas virtuales su nombre es Opennebula [2] , Este es un gestor de maquinas virtuales y solo soporta <a href="http://es.wikipedia.org/wiki/Xen">Xen</a> y <a href="http://es.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a> y esta planificado para su próxima versión que soporte tambien <a href="http://es.wikipedia.org/wiki/VMware">VMware</a>.</p>
<p>Características</p>
<ul>
<li>Arquitectura abierta y interfaces que permiten su integración con otras herramientas de virtualizacion.</li>
<li>Framework genérico para definir nuevas policitas de emplazamiento de VMs.</li>
<li>La politica de planificamiento por defecto determina el mejor host para instalar una VM dependiendo de los requerimientos.</li>
<li>Poderoso <a href="http://www.opennebula.org/doku.php?id=documentation:rel1.2:api">API</a> que permite controlar y monitorear las distintas VMs y recursos físicos.</li>
<li>Soporte de imagenes para transferir y clonar VMs , usando un componente modular que puede ser facilmente extendido y integrado con desarrollos de terceros.</li>
<li>Soporte de red habilitando la difinicion de redes virtuales.</li>
</ul>
<p><img class="aligncenter" title="gestor" src="http://www.opennebula.org/lib/exe/fetch.php?w=400&amp;h=&amp;cache=cache&amp;media=one-arch-new4.png" alt="" width="465" height="334" />Bueno espero que esto ayude dentro de poco iontentare colocar mis esperiencias sonre la instalacion de Pentaho,SugarCRM y Alfreso con un cherokee al frente</p>
<a href="http://polldaddy.com/poll/3974187/">View This Poll</a>
<p>Actualizacion de luiX_ via twitter <strong>http://bit.ly/cBvl0L</strong> o <strong>http://bit.ly/bbZvHE</strong></p>
<p>[1]http://www.glatelier.org/2010/07/kvm-o-xen-escogiendo-una-plataforma-de-virtualizacion-parte-1-2/</p>
<p>[2]http://dclavijo.blogspot.com/2008/12/opennebula-gestor-de-maquinas-virtuales.html</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/494/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=494&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2010/10/23/virtualizar-servidores/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>

		<media:content url="http://www.glatelier.org/wp-content/uploads/2010/07/xen_logo.gif" medium="image">
			<media:title type="html">Xen</media:title>
		</media:content>

		<media:content url="http://www.opennebula.org/lib/exe/fetch.php?w=400&#038;h=&#038;cache=cache&#038;media=one-arch-new4.png" medium="image">
			<media:title type="html">gestor</media:title>
		</media:content>
	</item>
		<item>
		<title>Teiid con Pentaho</title>
		<link>http://redcloverbi.wordpress.com/2010/10/12/teiid-con-pentaho/</link>
		<comments>http://redcloverbi.wordpress.com/2010/10/12/teiid-con-pentaho/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 11:23:45 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[Tecnologias]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=465</guid>
		<description><![CDATA[Teiid es un sistema de virtualización de datos que permite a las aplicaciones utilizar los datos de múltiples y heterogéneas bases de datos. Teiid se compone de herramientas, componentes y servicios para crear y ejecutar servicios . A través de la abstracción y la federación, y acceder a los datos integrados en tiempo real a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=465&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="logo" src="https://www.jboss.org/dms/teiid/images/teiid_banner.png" alt="" width="803" height="110" /></p>
<p>Teiid es un sistema de virtualización de datos que permite a las aplicaciones utilizar los datos de múltiples y heterogéneas bases de datos.</p>
<p>Teiid se compone de herramientas, componentes y servicios para crear y ejecutar servicios . A través de la abstracción y la federación, y acceder a los datos integrados en tiempo real a través de fuentes de datos distribuidas sin copiar o mover datos de su sistema de registro.</p>
<div><img src="http://www.google.com/images/cleardot.gif" alt="" /></div>
<p style="text-align:center;"><img class="aligncenter" title="esquema" src="http://www.jboss.org/teiid/mainColumnParagraphs/0/image/main2.png" alt="" width="414" height="336" /></p>
<p style="text-align:center;">&nbsp;</p>
<p style="text-align:left;">A dia de  hoy mucha gente quiere virtualizar  servidores , bases de datos , etc.. pues con esta tecnología es posible ahi va el link con el manual <a href="http://wiki.pentaho.com//display/COM/Query+Federation+using+Teiid">http://wiki.pentaho.com//display/COM/Query+Federation+using+Teiid</a></p>
<p style="text-align:center;">&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/465/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=465&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2010/10/12/teiid-con-pentaho/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>

		<media:content url="https://www.jboss.org/dms/teiid/images/teiid_banner.png" medium="image">
			<media:title type="html">logo</media:title>
		</media:content>

		<media:content url="http://www.google.com/images/cleardot.gif" medium="image" />

		<media:content url="http://www.jboss.org/teiid/mainColumnParagraphs/0/image/main2.png" medium="image">
			<media:title type="html">esquema</media:title>
		</media:content>
	</item>
		<item>
		<title>MySql optimizar</title>
		<link>http://redcloverbi.wordpress.com/2010/07/31/mysql-optimizar/</link>
		<comments>http://redcloverbi.wordpress.com/2010/07/31/mysql-optimizar/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 22:16:37 +0000</pubDate>
		<dc:creator>ravamo</dc:creator>
				<category><![CDATA[Tecnologias]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[openSource]]></category>

		<guid isPermaLink="false">http://redcloverbi.wordpress.com/?p=467</guid>
		<description><![CDATA[Siempre se tienen problemas con las bases de datos siempre se ponen con el hecho de optimizar y conseguir mas rendimientos Yo últimamente me decanto mas por bases de datos de NoSql estoy cambiando las de Oracle Oracle por Hadopp o Casandara y mysql por Neo pero siempre quedan sitio para las tradicionales como MySql y siempre [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=467&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Siempre se tienen problemas con las bases de datos siempre se ponen con el hecho de optimizar y conseguir mas rendimientos<br />
Yo últimamente me decanto mas por bases de datos de NoSql estoy cambiando las de Oracle Oracle por Hadopp o Casandara y mysql por Neo</p>
<p style="text-align:justify;">pero siempre quedan sitio para las tradicionales como MySql y siempre estoy con lo mismo ademas como en los sitios donde trabajo ya sea por desconocimiento o por reducción de bastos el perfil de DBA no lo cubren así que siempre ando con el tema de las bases de datos ahora pongo algunas cosas que suelo usar.</p>
<p style="text-align:justify;"><span id="more-467"></span></p>
<p>Ahora adjunto algunos consejos para las  tunning para mysql son muy conocidos pero al final siempre vienen bien conocerlos</p>
<p>1. Usar el comando Explain</p>
<p>El comando Explain explica como se lleva a cabo una consulta SELECT, como se usan los índices y como se unen las tablas. La forma de utilizarlo es la siguiente:</p>
<p>Explain select * from tabla</p>
<p>Ahora, en lugar de ejecutar la consulta, se mostrará un listado con la información ya mencionada anteriormente. Esto es muy útil para optimizar las consultas. <a href="http://www.mysql-hispano.org/page.php?id=29&amp;pag=8" target="_blank">Más información</a>.</p>
<p>2. Usar permisos poco complejos</p>
<p>Por defecto, el usuario que utilizamos para conectar nuestra aplicación a la Base de datos, goza todos los <strong>permisos MySQL</strong> . Sin embargo, el utilizar un usuario con sólo los permisos necesarios (para la publicación, por ejemplo), permiten a  <a href="http://www.baluart.net/categoria/mysql" target="_blank">MySQL</a> reducir la comprobación de cada uno de los permisos, cada vez que el cliente MySQL ejecute las sentencias (INSERT, por ejemplo).</p>
<p>3. Hacer BENCHMARK() a nuestras expresiones</p>
<p>Si tenemos un problema de rendimiento con una expresión que ya hemos identificado, una excelente manera de comprobar su optimización es utilizando la función <strong>benchmark()</strong>. Su sintaxis es la siguiente:</p>
<p>BENCHMARK(loop_count,expression)</p>
<p>Esta función siempre devuelve un valor cero, pero además imprime el tiempo que se ha demorado en el cliente final (no el tiempo de CPU en el servidor). <a href="http://dev.mysql.com/doc/refman/5.0/es/information-functions.html">Más información </a>.</p>
<p>4. Optimizar la cláusula WHERE</p>
<p>Estos son algunos consejos para optimizar WHERE:</p>
<ul>
<li>Remover los paréntesis innecesarios. Por ejemplo: DE (a&lt;b AND b=c) AND a=5 A b&gt;5 AND b=c AND a=5. <a href="http://dev.mysql.com/doc/refman/5.0/es/where-optimizations.html" target="_blank">Más información</a>.</li>
<li><strong>COUNT(*)</strong> esta optimizado para devolver un SELECT de manera mucho más rápida, siempre y cuando sea a una tabla y sin usar WHERE. Por ejemplo: SELECT COUNT(*) FROM tabla</li>
<li>La opción <strong>SQL_SMALL_RESULT</strong> , puede usarse con GROUP BY o DISTINCT para indicar que el conjunto de resultados es pequeño. En este caso, <strong>MySQL</strong> utiliza tablas temporales muy rápidas para almacenar la tabla resultante en lugar de usar ordenación.</li>
</ul>
<p>5. Utilizar la sentencia OPTIMIZE TABLE</p>
<p><strong>OPTIMIZE TABLE</strong> debe usarse si se ha eliminado gran parte de la tabla o si se han hecho varios cambios en la misma. Optimize Table desfragmenta la tabla, la repara y la ordena. <a href="http://dev.mysql.com/doc/refman/5.0/es/optimize-table.html" target="_blank">Más información</a>.</p>
<p>6. Evitar los tipos de columna de longitud variable</p>
<p>Los campos con longitud fija (CHAR, por ejemplo) son más rápidos que los de longitud variable (VARCHAR, por ejemplo). Pero, como contrapartida, ocupan más espacio en disco. Aún así, para las tablas <strong>MyISAM</strong>, se recomienda evitar el uso de las columnas de longitud variable (VARCHAR, BLOB, and TEXT).</p>
<p>7. Insert Delayed</p>
<p>Se recomienda utilizar <strong>INSERT DELAYED</strong> cuando los clientes no pueden esperar a que el INSERT se complete ó cuando no sea necesario conocer que los datos han sido escritos correctamente.</p>
<p>Cuando se usa INSERT DELAYED, se obtiene una confirmación inmediata por parte del servidor. La data se almacena en una cola para ser insertada cuando la tabla no esté en uso por ningún otro proceso. Además, los <strong>INSERT</strong> en cola son agrupados en bloques lo que aumenta la rapidez de su ejecución.</p>
<p>8. Priorizar las sentencias</p>
<p>Aquí explicamos dos maneras:</p>
<ul>
<li>Utilizar INSERT LOW_PRIORITY en los INSERT, cuando se desee priorizar las consultas SELECT sobre las INSERT. El INSERT debe esperar hasta que no hayan otros clientes leyendo la tabla.</li>
<li>Utilizar SELECT HIGH_PRIORITY en los SELECT, para priorizarlos sobre cualquier otro comando que se ejecute simultáneamente, ya sea para añadir o actualizar datos en la tabla.</li>
</ul>
<p>9. Insertar filas múltiples</p>
<p>Es recomendable ejecutar un insert multiple a varios inserts distintos. La sintaxis es:</p>
<p>INSERT INTO table (col1, col2) VALUES (&#8216;value1&#8242;, 1), (&#8216;value2&#8242;, 2), (&#8216;value3&#8242;, 3)</p>
<p>10. Sincronizar tipos de datos</p>
<p>La idea es la siguiente. Si se tienen columnas que van a almacenar la misma información, pero están en distintas tablas, es aconsejable que sean del mismo tipo de datos. De esta manera, los<strong>JOINS</strong> que se ejecuten entre ellas, serán mucho más rápidos.</p>
<p><a title="Tuning-Primer :: Script de optimización de MySQl" href="http://www.day32.com/MySQL/tuning-primer.sh">Tuning-Prime</a></p>
<p>Un buen script que analizará el rendimiento de MySQL es Tuning-Primer. Nos dará consejos para establecer algunas variables de la configuración, basándose en la información que proporciona el servidor.</p>
<p><pre class="brush: bash;">
#!/bin/sh

#########################################################################
#									#
#	MySQL performance tuning primer script				#
#	Writen by: Matthew Montgomery &lt;mmontgomery@mysql.com&gt;		#
#	Inspired by: MySQLARd (http://gert.sos.be/demo/mysqlar/)	#
#	Version: 1.5-r5		Released: 2009-11-22			#
#	Licenced under GPLv2                                            #
#									#
#########################################################################

#########################################################################
#									#
# Little known feature: 1st argument is execution mode			#
#									#
#	Usage: ./tuning-primer.sh [ mode ] 				#
#									#
#	Available Modes: 						#
#		all : 		perform all checks (default)		#
#		prompt : 	prompt for login credintials and socket	#
#				and execution mode			#
# 		mem, memory : 	run checks for tunable options which	#
#				effect memory usage			#
#		disk, file :	run checks for options which effect	#
#				i/o performance or file handle limits	#
#		innodb :	run InnoDB checks /* to be improved */	#
#		misc : 		run checks for that don't categorise	#
#				well Slow Queries, Binary logs,		#
#				Used Connections and Worker Threads	#
#########################################################################
#									#
# Set this socket variable ONLY if you have multiple instances running	#
# or we are unable to find your socket, and you don't want to to be	#
# prompted for input each time you run this script.			#
#									#
#########################################################################
socket=

export black='&#092;&#048;33[0m'
export boldblack='&#092;&#048;33[1;0m'
export red='&#092;&#048;33[31m'
export boldred='&#092;&#048;33[1;31m'
export green='&#092;&#048;33[32m'
export boldgreen='&#092;&#048;33[1;32m'
export yellow='&#092;&#048;33[33m'
export boldyellow='&#092;&#048;33[1;33m'
export blue='&#092;&#048;33[34m'
export boldblue='&#092;&#048;33[1;34m'
export magenta='&#092;&#048;33[35m'
export boldmagenta='&#092;&#048;33[1;35m'
export cyan='&#092;&#048;33[36m'
export boldcyan='&#092;&#048;33[1;36m'
export white='&#092;&#048;33[37m'
export boldwhite='&#092;&#048;33[1;37m'

cecho ()

## -- Function to easliy print colored text -- ##

	# Color-echo.
	# Argument $1 = message
	# Argument $2 = color
{
local default_msg=&quot;No message passed.&quot;

message=${1:-$default_msg}	# Defaults to default message.

#change it for fun
#We use pure names
color=${2:-black}		# Defaults to black, if not specified.

case $color in
	black)
		 printf &quot;$black&quot; ;;
	boldblack)
		 printf &quot;$boldblack&quot; ;;
	red)
		 printf &quot;$red&quot; ;;
	boldred)
		 printf &quot;$boldred&quot; ;;
	yellow)
		 printf &quot;$yellow&quot; ;;
	boldyellow)
		 printf &quot;$boldyellow&quot; ;;
	blue)
		 printf &quot;$blue&quot; ;;
	boldblue)
		 printf &quot;$boldblue&quot; ;;
	magenta)
		 printf &quot;$magenta&quot; ;;
	boldmagenta)
		 printf &quot;$boldmagenta&quot; ;;
	cyan)
		 printf &quot;$cyan&quot; ;;
	boldcyan)
		 printf &quot;$boldcyan&quot; ;;
	white)
		 printf &quot;$white&quot; ;;
	boldwhite)
		 printf &quot;$boldwhite&quot; ;;
esac
  printf &quot;%s\n&quot;  &quot;$message&quot;
  tput sgr0			# Reset to normal.
  printf &quot;$black&quot;

return
}

cechon ()

## -- Function to easliy print colored text -- ##

	# Color-echo.
	# Argument $1 = message
	# Argument $2 = color
{
local default_msg=&quot;No message passed.&quot;
				# Doesn't really need to be a local variable.

message=${1:-$default_msg}	# Defaults to default message.

#change it for fun
#We use pure names
color=${2:-black}		# Defaults to black, if not specified.

case $color in
	black)
		 printf &quot;$black&quot; ;;
	boldblack)
		 printf &quot;$boldblack&quot; ;;
	red)
		 printf &quot;$red&quot; ;;
	boldred)
		 printf &quot;$boldred&quot; ;;
	yellow)
		 printf &quot;$yellow&quot; ;;
	boldyellow)
		 printf &quot;$boldyellow&quot; ;;
	blue)
		 printf &quot;$blue&quot; ;;
	boldblue)
		 printf &quot;$boldblue&quot; ;;
	magenta)
		 printf &quot;$magenta&quot; ;;
	boldmagenta)
		 printf &quot;$boldmagenta&quot; ;;
	cyan)
		 printf &quot;$cyan&quot; ;;
	boldcyan)
		 printf &quot;$boldcyan&quot; ;;
	white)
		 printf &quot;$white&quot; ;;
	boldwhite)
		 printf &quot;$boldwhite&quot; ;;
esac
  printf &quot;%s&quot;  &quot;$message&quot;
  tput sgr0			# Reset to normal.
  printf &quot;$black&quot;

return
}

print_banner () {

## -- Banner -- ##

cecho &quot;	-- MYSQL PERFORMANCE TUNING PRIMER --&quot; boldblue
cecho &quot;	     - By: Matthew Montgomery -&quot; black

}

## -- Find the location of the mysql.sock file -- ##

check_for_socket () {
	if [ -z &quot;$socket&quot; ] ; then
		# Use ~/my.cnf version
		if [ -f ~/.my.cnf ] ; then
			cnf_socket=$(grep ^socket ~/.my.cnf | awk -F \= '{ print $2 }' | head -1)
		fi
		if [ -S &quot;$cnf_socket&quot; ] ; then
			socket=$cnf_socket
		elif [ -S /var/lib/mysql/mysql.sock ] ; then
			socket=/var/lib/mysql/mysql.sock
		elif [ -S /var/run/mysqld/mysqld.sock ] ; then
			socket=/var/run/mysqld/mysqld.sock
		elif [ -S /tmp/mysql.sock ] ; then
			socket=/tmp/mysql.sock
		else
			if [ -S &quot;$ps_socket&quot; ] ; then
			socket=$ps_socket
			fi
		fi
	fi
	if [ -S &quot;$socket&quot; ] ; then
		echo UP &gt; /dev/null
	else
		cecho &quot;No valid socket file \&quot;$socket\&quot; found!&quot; boldred
		cecho &quot;The mysqld process is not running or it is installed in a custom location.&quot; red
		cecho &quot;If you are sure mysqld is running, execute script in \&quot;prompt\&quot; mode or set &quot; red
		cecho &quot;the socket= variable at the top of this script&quot; red
		exit 1
	fi
}

check_for_plesk_passwords () {

## -- Check for the existance of plesk and login using it's credentials -- ##

	if [ -f /etc/psa/.psa.shadow ] ; then
	        mysql=&quot;mysql -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)&quot;
	        mysqladmin=&quot;mysqladmin -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)&quot;
	else
	        mysql=&quot;mysql&quot;
	        mysqladmin=&quot;mysqladmin&quot;
	        # mysql=&quot;mysql -S $socket&quot;
	        # mysqladmin=&quot;mysqladmin -S $socket&quot;
	fi
}

check_mysql_login () {

## -- Test for running mysql -- ##

	is_up=$($mysqladmin ping 2&gt;&amp;1)
	if [ &quot;$is_up&quot; = &quot;mysqld is alive&quot; ] ; then
		echo UP &gt; /dev/null
	 	# echo $is_up
	elif [ &quot;$is_up&quot; != &quot;mysqld is alive&quot; ] ; then
		printf &quot;\n&quot;
		cecho &quot;Using login values from ~/.my.cnf&quot;
		cecho &quot;- INITIAL LOGIN ATTEMPT FAILED -&quot; boldred
		if [ -z $prompted ] ; then
		find_webmin_passwords
		else
			return 1
		fi

	else
		cecho &quot;Unknow exit status&quot; red
		exit -1
	fi
}

final_login_attempt () {
        is_up=$($mysqladmin ping 2&gt;&amp;1)
        if [ &quot;$is_up&quot; = &quot;mysqld is alive&quot; ] ; then
                echo UP &gt; /dev/null
        elif [ &quot;$is_up&quot; != &quot;mysqld is alive&quot; ] ; then
                cecho &quot;- FINAL LOGIN ATTEMPT FAILED -&quot; boldred
		cecho &quot;Unable to log into socket: $socket&quot; boldred
                exit 1
        fi
}

second_login_failed () {

## -- create a ~/.my.cnf and exit when all else fails -- ##

	cecho &quot;Could not auto detect login info!&quot;
	cecho &quot;Found Sockets: $found_socks&quot;
	cecho &quot;Using: $socket&quot; red
	read -p &quot;Would you like to provide a different socket?: [y/N] &quot; REPLY
		case $REPLY in
			yes | y | Y | YES)
			read -p &quot;Socket: &quot; socket
			;;
		esac
	read -p &quot;Do you have your login handy ? [y/N] : &quot; REPLY
	case $REPLY in
		yes | y | Y | YES)
		answer1='yes'
		read -p &quot;User: &quot; user
		read -rp &quot;Password: &quot; pass
		if [ -z $pass ] ; then
		export mysql=&quot;$mysql -S$socket -u$user&quot;
		export mysqladmin=&quot;$mysqladmin -S$socket -u$user&quot;
		else
		export mysql=&quot;$mysql -S$socket -u$user -p$pass&quot;
		export mysqladmin=&quot;$mysqladmin -S$socket -u$user -p$pass&quot;
		fi
		;;
		*)
		cecho &quot;Please create a valid login to MySQL&quot;
		cecho &quot;Or, set correct values for  'user=' and 'password=' in ~/.my.cnf&quot;
		;;
	esac
	cecho &quot; &quot;
	read -p &quot;Would you like me to create a ~/.my.cnf file for you? [y/N] : &quot; REPLY
        case $REPLY in
	        yes | y | Y | YES)
		answer2='yes'
		if [ ! -f ~/.my.cnf ] ; then
			umask 077
			printf &quot;[client]\nuser=$user\npassword=$pass\nsocket=$socket&quot; &gt; ~/.my.cnf
			if [ &quot;$answer1&quot; != 'yes' ] ; then
				exit 1
			else
				final_login_attempt
				return 0
			fi
		else
			printf &quot;\n&quot;
			cecho &quot;~/.my.cnf already exists!&quot; boldred
			printf &quot;\n&quot;
			read -p &quot;Replace ? [y/N] : &quot; REPLY
			if [ &quot;$REPLY&quot; = 'y' ] || [ &quot;$REPLY&quot; = 'Y' ] ; then
			printf &quot;[client]\nuser=$user\npassword=$pass\socket=$socket&quot; &gt; ~/.my.cnf
				if [ &quot;$answer1&quot; != 'yes' ] ; then
					exit 1
				else
					final_login_attempt
					return 0
				fi
			else
				cecho &quot;Please set the 'user=' and 'password=' and 'socket=' values in ~/.my.cnf&quot;
				exit 1
			fi
		fi
		;;
		*)
		if [ &quot;$answer1&quot; != 'yes' ] ; then
			exit 1
		else
			final_login_attempt
			return 0
		fi
		;;
	esac
}

find_webmin_passwords () {

## -- populate the .my.cnf file using values harvested from Webmin -- ##

	cecho &quot;Testing for stored webmin passwords:&quot;
	if [ -f /etc/webmin/mysql/config ] ; then
		user=$(grep ^login= /etc/webmin/mysql/config | cut -d &quot;=&quot; -f 2)
		pass=$(grep ^pass= /etc/webmin/mysql/config | cut -d &quot;=&quot; -f 2)
		if [  $user ] &amp;&amp; [ $pass ] &amp;&amp; [ ! -f ~/.my.cnf  ] ; then
			cecho &quot;Setting login info as User: $user Password: $pass&quot;
			touch ~/.my.cnf
			chmod 600 ~/.my.cnf
			printf &quot;[client]\nuser=$user\npassword=$pass&quot; &gt; ~/.my.cnf
			cecho &quot;Retrying login&quot;
			is_up=$($mysqladmin ping 2&gt;&amp;1)
			if [ &quot;$is_up&quot; = &quot;mysqld is alive&quot;  ] ; then
				echo UP &gt; /dev/null
			else
				second_login_failed
			fi
		echo
		else
			second_login_failed
		echo
		fi
	else
	cecho &quot; None Found&quot; boldred
		second_login_failed
	fi
}

#########################################################################
#									#
#  Function to pull MySQL status variable				#
#									#
#  Call using :								#
#	mysql_status \'Mysql_status_variable\' bash_dest_variable	#
#									#
#########################################################################

mysql_status () {
	local status=$($mysql -Bse &quot;show /*!50000 global */ status like $1&quot; | awk '{ print $2 }')
	export &quot;$2&quot;=$status
}

#########################################################################
#									#
#  Function to pull MySQL server runtime variable			#
#									#
#  Call using :								#
#	mysql_variable \'Mysql_server_variable\' bash_dest_variable	#
#	- OR -								#
#	mysql_variableTSV \'Mysql_server_variable\' bash_dest_variable	#
#									#
#########################################################################

mysql_variable () {
	local variable=$($mysql -Bse &quot;show /*!50000 global */ variables like $1&quot; | awk '{ print $2 }')
	export &quot;$2&quot;=$variable
}
mysql_variableTSV () {
        local variable=$($mysql -Bse &quot;show /*!50000 global */ variables like $1&quot; | awk -F \t '{ print $2 }')
        export &quot;$2&quot;=$variable
}

float2int () {
        local variable=$(echo &quot;$1 / 1&quot; | bc -l)
        export &quot;$2&quot;=$variable
}

divide () {

# -- Divide two intigers -- #

	usage=&quot;$0 dividend divisor '$variable' scale&quot;
	if [ $1 -ge 1 ]	; then
		dividend=$1
	else
		cecho &quot;Invalid Dividend&quot; red
		echo $usage
		exit 1
	fi
	if [ $2 -ge 1 ] ; then
		divisor=$2
	else
		cecho &quot;Invalid Divisor&quot; red
		echo $usage
		exit 1
	fi
	if [ ! -n $3 ] ; then
		cecho &quot;Invalid variable name&quot; red
		echo $usage
		exit 1
	fi
	if [ -z $4 ] ; then
		scale=2
	elif [ $4 -ge 0 ] ; then
		scale=$4
	else
		cecho &quot;Invalid scale&quot; red
		echo $usage
		exit 1
	fi
	export $3=$(echo &quot;scale=$scale; $dividend / $divisor&quot; | bc -l)
}

human_readable () {

#########################################################################
#									#
#  Convert a value in to human readable size and populate a variable	#
#  with the result.							#
#									#
#  Call using:								#
#	human_readable $value 'variable name' [ places of precision]	#
#									#
#########################################################################

	## value=$1
	## variable=$2
	scale=$3

	if [ $1 -ge 1073741824 ] ; then
		if [ -z $3 ] ; then
			scale=2
		fi
		divide $1 1073741824 &quot;$2&quot; $scale
		unit=&quot;G&quot;
	elif [ $1 -ge 1048576 ] ; then
		if [ -z $3 ] ; then
			scale=0
		fi
		divide $1 1048576 &quot;$2&quot; $scale
	        unit=&quot;M&quot;
	elif [ $1 -ge 1024 ] ; then
		if [ -z $3 ] ; then
			scale=0
		fi
		divide $1 1024 &quot;$2&quot; $scale
	        unit=&quot;K&quot;
	else
		export &quot;$2&quot;=$1
	        unit=&quot;bytes&quot;
	fi
	# let &quot;$2&quot;=$HR
}

human_readable_time () {

########################################################################
#								       #
#	Function to produce human readable time                        #
#								       #
########################################################################

	usage=&quot;$0 seconds 'variable'&quot;
	if [ -z $1 ] || [ -z $2 ] ; then
		cecho $usage red
		exit 1
	fi
	days=$(echo &quot;scale=0 ; $1 / 86400&quot; | bc -l)
	remainder=$(echo &quot;scale=0 ; $1 % 86400&quot; | bc -l)
	hours=$(echo &quot;scale=0 ; $remainder / 3600&quot; | bc -l)
	remainder=$(echo &quot;scale=0 ; $remainder % 3600&quot; | bc -l)
	minutes=$(echo &quot;scale=0 ; $remainder / 60&quot; | bc -l)
	seconds=$(echo &quot;scale=0 ; $remainder % 60&quot; | bc -l)
	export $2=&quot;$days days $hours hrs $minutes min $seconds sec&quot;
}

check_mysql_version () {

## -- Print Version Info -- ##

	mysql_variable \'version\' mysql_version
	mysql_variable \'version_compile_machine\' mysql_version_compile_machine

if [ &quot;$major_version&quot; = '3.23' ] || [ &quot;$major_version&quot; = '4.0' ] ; then
	cecho &quot;MySQL Version $mysql_version $mysql_version_compile_machine is EOL please upgrade to MySQL 4.1 or later&quot; boldred
else
	cecho &quot;MySQL Version $mysql_version $mysql_version_compile_machine&quot;
fi

}

post_uptime_warning () {

#########################################################################
#									#
#  Present a reminder that mysql must run for a couple of days to	#
#  build up good numbers in server status variables before these tuning	#
#  suggestions should be used.						#
#									#
#########################################################################

	mysql_status \'Uptime\' uptime
	mysql_status \'Threads_connected\' threads
	queries_per_sec=$(($questions/$uptime))
	human_readable_time $uptime uptimeHR

	cecho &quot;Uptime = $uptimeHR&quot;
	cecho &quot;Avg. qps = $queries_per_sec&quot;
	cecho &quot;Total Questions = $questions&quot;
	cecho &quot;Threads Connected = $threads&quot;
	echo

	if [ $uptime -gt 172800 ] ; then
		cecho &quot;Server has been running for over 48hrs.&quot;
		cecho &quot;It should be safe to follow these recommendations&quot;
	else
		cechon &quot;Warning: &quot; boldred
		cecho &quot;Server has not been running for at least 48hrs.&quot; boldred
		cecho &quot;It may not be safe to use these recommendations&quot; boldred

	fi
	echo &quot;&quot;
	cecho &quot;To find out more information on how each of these&quot; red
	cecho &quot;runtime variables effects performance visit:&quot; red
	if [ &quot;$major_version&quot; = '3.23' ] || [ &quot;$major_version&quot; = '4.0' ] || [ &quot;$major_version&quot; = '4.1' ] ; then
	cecho &quot;http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html&quot; boldblue
	elif [ &quot;$major_version&quot; = '5.0' ] || [ &quot;$major_version&quot; = '5.1' ] ; then
	cecho &quot;http://dev.mysql.com/doc/refman/$major_version/en/server-system-variables.html&quot; boldblue
	else
	cecho &quot;UNSUPPORTED MYSQL VERSION&quot; boldred
	exit 1
	fi
	cecho &quot;Visit http://www.mysql.com/products/enterprise/advisors.html&quot; boldblue
	cecho &quot;for info about MySQL's Enterprise Monitoring and Advisory Service&quot; boldblue
}

check_slow_queries () {

## -- Slow Queries -- ##

	cecho &quot;SLOW QUERIES&quot; boldblue

	mysql_status \'Slow_queries\' slow_queries
	mysql_variable \'long_query_time\' long_query_time
	mysql_variable \'log%queries\' log_slow_queries

	prefered_query_time=5
	if [ -e /etc/my.cnf ] ; then
		if [ -z $log_slow_queries ] ; then
			log_slow_queries=$(grep log-slow-queries /etc/my.cnf)
		fi
	fi

	if [ &quot;$log_slow_queries&quot; = 'ON' ] ; then
		cecho &quot;The slow query log is enabled.&quot;
	elif [ &quot;$log_slow_queries&quot; = 'OFF' ] ; then
		cechon &quot;The slow query log is &quot;
		cechon &quot;NOT&quot; boldred
		cecho &quot; enabled.&quot;
	elif [ -z $log_slow_queries ] ; then
		cechon &quot;The slow query log is &quot;
		cechon &quot;NOT&quot; boldred
		cecho &quot; enabled.&quot;
	else
		cecho &quot;Error: $log_slow_queries&quot; boldred
	fi
	cecho &quot;Current long_query_time = $long_query_time sec.&quot;
	cechon &quot;You have &quot;
	cechon &quot;$slow_queries&quot; boldred
	cechon &quot; out of &quot;
	cechon &quot;$questions&quot; boldred
	cecho &quot; that take longer than $long_query_time sec. to complete&quot;

	float2int long_query_time long_query_timeInt

	if [ $long_query_timeInt -gt $prefered_query_time ] ; then
                cecho &quot;Your long_query_time may be too high, I typically set this under $prefered_query_time sec.&quot; red
	else
		cecho &quot;Your long_query_time seems to be fine&quot; green
	fi

}

check_binary_log () {

## -- Binary Log -- ##

	cecho &quot;BINARY UPDATE LOG&quot; boldblue

	mysql_variable \'log_bin\' log_bin
	mysql_variable \'max_binlog_size\' max_binlog_size
	mysql_variable \'expire_logs_days\' expire_logs_days
	mysql_variable \'sync_binlog\' sync_binlog
	#  mysql_variable \'max_binlog_cache_size\' max_binlog_cache_size

	if [ &quot;$log_bin&quot; = 'ON' ] ; then
		cecho &quot;The binary update log is enabled&quot;
		if [ -z &quot;$max_binlog_size&quot; ] ; then
			cecho &quot;The max_binlog_size is not set. The binary log will rotate when it reaches 1GB.&quot; red
		fi
		if [ &quot;$expire_logs_days&quot; -eq 0 ] ; then
			cecho &quot;The expire_logs_days is not set.&quot; boldred
			cechon &quot;The mysqld will retain the entire binary log until &quot; red
			cecho &quot;RESET MASTER or PURGE MASTER LOGS commands are run manually&quot; red
			cecho &quot;Setting expire_logs_days will allow you to remove old binary logs automatically&quot;  yellow
			cecho &quot;See http://dev.mysql.com/doc/refman/$major_version/en/purge-master-logs.html&quot; yellow
		fi
		if [ &quot;$sync_binlog&quot; = 0 ] ; then
			cecho &quot;Binlog sync is not enabled, you could loose binlog records during a server crash&quot; red
		fi
	else
		cechon &quot;The binary update log is &quot;
		cechon &quot;NOT &quot; boldred
		cecho &quot;enabled.&quot;
		cecho &quot;You will not be able to do point in time recovery&quot; red
		cecho &quot;See http://dev.mysql.com/doc/refman/$major_version/en/point-in-time-recovery.html&quot; yellow
	fi
}

check_used_connections () {

## -- Used Connections -- ##

	mysql_variable \'max_connections\' max_connections
	mysql_status \'Max_used_connections\' max_used_connections
	mysql_status \'Threads_connected\' threads_connected

	connections_ratio=$(($max_used_connections*100/$max_connections))

	cecho &quot;MAX CONNECTIONS&quot; boldblue
	cecho &quot;Current max_connections = $max_connections&quot;
	cecho &quot;Current threads_connected = $threads_connected&quot;
	cecho &quot;Historic max_used_connections = $max_used_connections&quot;
	cechon &quot;The number of used connections is &quot;
	if [ $connections_ratio -ge 85 ] ; then
		txt_color=red
		error=1
	elif [ $connections_ratio -le 10 ] ; then
		txt_color=red
		error=2
	else
		txt_color=green
		error=0
	fi
	# cechon &quot;$max_used_connections &quot; $txt_color
	# cechon &quot;which is &quot;
	cechon &quot;$connections_ratio% &quot; $txt_color
	cecho &quot;of the configured maximum.&quot;

	if [ $error -eq 1 ] ; then
		cecho &quot;You should raise max_connections&quot; $txt_color
	elif [ $error -eq 2 ] ; then
		cecho &quot;You are using less than 10% of your configured max_connections.&quot; $txt_color
		cecho &quot;Lowering max_connections could help to avoid an over-allocation of memory&quot; $txt_color
		cecho &quot;See \&quot;MEMORY USAGE\&quot; section to make sure you are not over-allocating&quot; $txt_color
	else
		cecho &quot;Your max_connections variable seems to be fine.&quot; $txt_color
	fi
	unset txt_color
}

check_threads() {

## -- Worker Threads -- ##

	cecho &quot;WORKER THREADS&quot; boldblue

	mysql_status \'Threads_created\' threads_created1
	sleep 1
	mysql_status \'Threads_created\' threads_created2

	mysql_status \'Threads_cached\' threads_cached
	mysql_status \'Uptime\' uptime
	mysql_variable \'thread_cache_size\' thread_cache_size

	historic_threads_per_sec=$(($threads_created1/$uptime))
	current_threads_per_sec=$(($threads_created2-$threads_created1))

	cecho &quot;Current thread_cache_size = $thread_cache_size&quot;
	cecho &quot;Current threads_cached = $threads_cached&quot;
	cecho &quot;Current threads_per_sec = $current_threads_per_sec&quot;
	cecho &quot;Historic threads_per_sec = $historic_threads_per_sec&quot;

	if [ $historic_threads_per_sec -ge 2 ] &amp;&amp; [ $threads_cached -le 1 ] ; then
		cecho &quot;Threads created per/sec are overrunning threads cached&quot; red
		cecho &quot;You should raise thread_cache_size&quot; red
	elif [ $current_threads_per_sec -ge 2 ] ; then
		cecho &quot;Threads created per/sec are overrunning threads cached&quot; red
		cecho &quot;You should raise thread_cache_size&quot; red
	else
		cecho &quot;Your thread_cache_size is fine&quot; green
	fi
}

check_key_buffer_size () {

## -- Key buffer Size -- ##

	cecho &quot;KEY BUFFER&quot; boldblue

	mysql_status \'Key_read_requests\' key_read_requests
	mysql_status \'Key_reads\' key_reads
	mysql_status \'Key_blocks_used\' key_blocks_used
	mysql_status \'Key_blocks_unused\' key_blocks_unused
	mysql_variable \'key_cache_block_size\' key_cache_block_size
	mysql_variable \'key_buffer_size\' key_buffer_size
        mysql_variable \'datadir\' datadir
        mysql_variable \'version_compile_machine\' mysql_version_compile_machine
	myisam_indexes=$($mysql -Bse &quot;/*!50000 SELECT IFNULL(SUM(INDEX_LENGTH),0) from information_schema.TABLES where ENGINE='MyISAM' */&quot;)

	if [ -z $myisam_indexes ] ; then
		myisam_indexes=$(find $datadir -name '*.MYI' -exec du $duflags '{}' \; 2&gt;&amp;1 | awk '{ s += $1 } END { printf(&quot;%.0f\n&quot;, s )}')
	fi

        if [ $key_reads -eq 0 ] ; then
                cecho &quot;No key reads?!&quot; boldred
                cecho &quot;Seriously look into using some indexes&quot; red
                key_cache_miss_rate=0
                key_buffer_free=$(echo &quot;$key_blocks_unused * $key_cache_block_size / $key_buffer_size * 100&quot; | bc -l )
                key_buffer_freeRND=$(echo &quot;scale=0; $key_buffer_free / 1&quot; | bc -l)
        else
                key_cache_miss_rate=$(($key_read_requests/$key_reads))
                if [ ! -z $key_blocks_unused ] ; then
			key_buffer_free=$(echo &quot;$key_blocks_unused * $key_cache_block_size / $key_buffer_size * 100&quot; | bc -l )
                	key_buffer_freeRND=$(echo &quot;scale=0; $key_buffer_free / 1&quot; | bc -l)
                else
                        key_buffer_free='Unknown'
                        key_buffer_freeRND=75
                fi
        fi

	human_readable $myisam_indexes myisam_indexesHR
	cecho &quot;Current MyISAM index space = $myisam_indexesHR $unit&quot;

	human_readable  $key_buffer_size key_buffer_sizeHR
	cecho &quot;Current key_buffer_size = $key_buffer_sizeHR $unit&quot;
	cecho &quot;Key cache miss rate is 1 : $key_cache_miss_rate&quot;
	cecho &quot;Key buffer free ratio = $key_buffer_freeRND %&quot;

	if [ &quot;$major_version&quot; = '5.1' ] &amp;&amp; [ $mysql_version_num -lt '5123' ] ; then
		if [ $key_buffer_size -ge 4294967296 ] &amp;&amp; ( echo &quot;x86_64 ppc64 ia64 sparc64 i686&quot; | grep -q $mysql_version_compile_machine ) ; then
			cecho &quot;Using key_buffer_size &gt; 4GB will cause instability in versions prior to 5.1.23 &quot; boldred
			cecho &quot;See Bug#5731, Bug#29419, Bug#29446&quot; boldred
		fi
	fi
	if [ &quot;$major_version&quot; = '5.0' ] &amp;&amp; [ $mysql_version_num -lt '5052' ] ; then
		if [ $key_buffer_size -ge 4294967296 ] &amp;&amp; ( echo &quot;x86_64 ppc64 ia64 sparc64 i686&quot; | grep -q $mysql_version_compile_machine ) ; then
			cecho &quot;Using key_buffer_size &gt; 4GB will cause instability in versions prior to 5.0.52 &quot; boldred
			cecho &quot;See Bug#5731, Bug#29419, Bug#29446&quot; boldred
		fi
	fi
	if [ &quot;$major_version&quot; = '4.1' -o &quot;$major_version&quot; = '4.0' ] &amp;&amp; [ $key_buffer_size -ge 4294967296 ] &amp;&amp; ( echo &quot;x86_64 ppc64 ia64 sparc64 i686&quot; | grep -q $mysql_version_compile_machine ) ; then
		cecho &quot;Using key_buffer_size &gt; 4GB will cause instability in versions prior to 5.0.52 &quot; boldred
		cecho &quot;Reduce key_buffer_size to a safe value&quot; boldred
		cecho &quot;See Bug#5731, Bug#29419, Bug#29446&quot; boldred
	fi

	if [ $key_cache_miss_rate -le 100 ] &amp;&amp; [ $key_cache_miss_rate -gt 0 ] &amp;&amp; [ $key_buffer_freeRND -le 20 ]; then
		cecho &quot;You could increase key_buffer_size&quot; boldred
		cecho &quot;It is safe to raise this up to 1/4 of total system memory;&quot;
		cecho &quot;assuming this is a dedicated database server.&quot;
	elif [ $key_buffer_freeRND -le 20 ] &amp;&amp; [ $key_buffer_size -le $myisam_indexes ] ; then
		cecho &quot;You could increase key_buffer_size&quot; boldred
		cecho &quot;It is safe to raise this up to 1/4 of total system memory;&quot;
		cecho &quot;assuming this is a dedicated database server.&quot;
	elif [ $key_cache_miss_rate -ge 10000 ] || [ $key_buffer_freeRND -le 50  ] ; then
		cecho &quot;Your key_buffer_size seems to be too high.&quot; red
		cecho &quot;Perhaps you can use these resources elsewhere&quot; red
	else
		cecho &quot;Your key_buffer_size seems to be fine&quot; green
	fi
}

check_query_cache () {

## -- Query Cache -- ##

	cecho &quot;QUERY CACHE&quot; boldblue

	mysql_variable \'version\' mysql_version
	mysql_variable \'query_cache_size\' query_cache_size
	mysql_variable \'query_cache_limit\' query_cache_limit
	mysql_variable \'query_cache_min_res_unit\' query_cache_min_res_unit
	mysql_status \'Qcache_free_memory\' qcache_free_memory
	mysql_status \'Qcache_total_blocks\' qcache_total_blocks
	mysql_status \'Qcache_free_blocks\' qcache_free_blocks
	mysql_status \'Qcache_lowmem_prunes\' qcache_lowmem_prunes

	if [ -z $query_cache_size ] ; then
		cecho &quot;You are using MySQL $mysql_version, no query cache is supported.&quot; red
		cecho &quot;I recommend an upgrade to MySQL 4.1 or better&quot; red
	elif [ $query_cache_size -eq 0 ] ; then
		cecho &quot;Query cache is supported but not enabled&quot; red
		cecho &quot;Perhaps you should set the query_cache_size&quot; red
	else
		qcache_used_memory=$(($query_cache_size-$qcache_free_memory))
		qcache_mem_fill_ratio=$(echo &quot;scale=2; $qcache_used_memory * 100 / $query_cache_size&quot; | bc -l)
		qcache_mem_fill_ratioHR=$(echo &quot;scale=0; $qcache_mem_fill_ratio / 1&quot; | bc -l)

		cecho &quot;Query cache is enabled&quot; green
		human_readable $query_cache_size query_cache_sizeHR
		cecho &quot;Current query_cache_size = $query_cache_sizeHR $unit&quot;
		human_readable $qcache_used_memory qcache_used_memoryHR
		cecho &quot;Current query_cache_used = $qcache_used_memoryHR $unit&quot;
		human_readable $query_cache_limit query_cache_limitHR
		cecho &quot;Current query_cache_limit = $query_cache_limitHR $unit&quot;
		cecho &quot;Current Query cache Memory fill ratio = $qcache_mem_fill_ratio %&quot;
		if [ -z $query_cache_min_res_unit ] ; then
			cecho &quot;No query_cache_min_res_unit is defined.  Using MySQL &lt; 4.1 cache fragmentation can be inpredictable&quot; %yellow
		else
			human_readable $query_cache_min_res_unit query_cache_min_res_unitHR
			cecho &quot;Current query_cache_min_res_unit = $query_cache_min_res_unitHR $unit&quot;
		fi
		if [ $qcache_free_blocks -gt 2 ] &amp;&amp; [ $qcache_total_blocks -gt 0 ] ; then
			qcache_percent_fragmented=$(echo &quot;scale=2; $qcache_free_blocks * 100 / $qcache_total_blocks&quot; | bc -l)
			qcache_percent_fragmentedHR=$(echo &quot;scale=0; $qcache_percent_fragmented / 1&quot; | bc -l)
			if [ $qcache_percent_fragmentedHR -gt 20 ] ; then
				cecho &quot;Query Cache is $qcache_percent_fragmentedHR % fragmented&quot; red
				cecho &quot;Run \&quot;FLUSH QUERY CACHE\&quot; periodically to defragment the query cache memory&quot; red
				cecho &quot;If you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.&quot; red
			fi
		fi

		if [ $qcache_mem_fill_ratioHR -le 25 ] ; then
        	        cecho &quot;Your query_cache_size seems to be too high.&quot; red
	                cecho &quot;Perhaps you can use these resources elsewhere&quot; red
		fi
		if [ $qcache_lowmem_prunes -ge 50 ] &amp;&amp; [ $qcache_mem_fill_ratioHR -ge 80 ]; then
			cechon &quot;However, &quot;
			cechon &quot;$qcache_lowmem_prunes &quot; boldred
			cecho &quot;queries have been removed from the query cache due to lack of memory&quot;
			cecho &quot;Perhaps you should raise query_cache_size&quot; boldred
		fi
		cecho &quot;MySQL won't cache query results that are larger than query_cache_limit in size&quot; yellow
	fi

}

check_sort_operations () {

## -- Sort Operations -- ##

	cecho &quot;SORT OPERATIONS&quot; boldblue

	mysql_status \'Sort_merge_passes\' sort_merge_passes
	mysql_status \'Sort_scan\' sort_scan
	mysql_status \'Sort_range\' sort_range
	mysql_variable \'sort_buffer%\' sort_buffer_size
	mysql_variable \'read_rnd_buffer_size\' read_rnd_buffer_size

	total_sorts=$(($sort_scan+$sort_range))
	if [ -z $read_rnd_buffer_size ] ; then
		mysql_variable \'record_buffer\' read_rnd_buffer_size
	fi

	## Correct for rounding error in mysqld where 512K != 524288 ##
	sort_buffer_size=$(($sort_buffer_size+8))
	read_rnd_buffer_size=$(($read_rnd_buffer_size+8))

	human_readable $sort_buffer_size sort_buffer_sizeHR
	cecho &quot;Current sort_buffer_size = $sort_buffer_sizeHR $unit&quot;

	human_readable $read_rnd_buffer_size read_rnd_buffer_sizeHR
	cechon &quot;Current &quot;
	if [ &quot;$major_version&quot; = '3.23' ] ; then
		cechon &quot;record_rnd_buffer &quot;
	else
		cechon &quot;read_rnd_buffer_size &quot;
	fi
	cecho &quot;= $read_rnd_buffer_sizeHR $unit&quot;

	if [ $total_sorts -eq 0 ] ; then
		cecho &quot;No sort operations have been performed&quot;
		passes_per_sort=0
	fi
	if [ $sort_merge_passes -ne 0 ] ; then
		passes_per_sort=$(($sort_merge_passes/$total_sorts))
	else
		passes_per_sort=0
	fi

	if [ $passes_per_sort -ge 2 ] ; then
		cechon &quot;On average &quot;
		cechon &quot;$passes_per_sort &quot; boldred
		cecho &quot;sort merge passes are made per sort operation&quot;
		cecho &quot;You should raise your sort_buffer_size&quot;
		cechon &quot;You should also raise your &quot;
		if [ &quot;$major_version&quot; = '3.23' ] ; then
			cecho &quot;record_rnd_buffer_size&quot;
		else
			cecho &quot;read_rnd_buffer_size&quot;
		fi
	else
		cecho &quot;Sort buffer seems to be fine&quot; green
	fi
}

check_join_operations () {

## -- Joins -- ##

	cecho &quot;JOINS&quot; boldblue

	mysql_status \'Select_full_join\' select_full_join
	mysql_status \'Select_range_check\' select_range_check
	mysql_variable \'join_buffer%\' join_buffer_size

	## Some 4K is dropped from join_buffer_size adding it back to make sane ##
	## handling of human-readable conversion ##

	join_buffer_size=$(($join_buffer_size+4096))

	human_readable $join_buffer_size join_buffer_sizeHR 2

	cecho &quot;Current join_buffer_size = $join_buffer_sizeHR $unit&quot;
	cecho &quot;You have had $select_full_join queries where a join could not use an index properly&quot;

	if [ $select_range_check -eq 0 ] &amp;&amp; [ $select_full_join -eq 0 ] ; then
		cecho &quot;Your joins seem to be using indexes properly&quot; green
	fi
	if [ $select_full_join -gt 0 ] ; then
		print_error='true'
		raise_buffer='true'
	fi
	if [ $select_range_check -gt 0 ] ; then
		cecho &quot;You have had $select_range_check joins without keys that check for key usage after each row&quot; red
		print_error='true'
		raise_buffer='true'
	fi

	## For Debuging ##
	# print_error='true'
	if [ $join_buffer_size -ge 4194304 ] ; then
		cecho &quot;join_buffer_size &gt;= 4 M&quot; boldred
		cecho &quot;This is not advised&quot; boldred
		raise_buffer=
	fi

	if [ $print_error ] ; then
		if [ &quot;$major_version&quot; = '3.23' ] || [ &quot;$major_version&quot; = '4.0' ] ; then
			cecho &quot;You should enable \&quot;log-long-format\&quot; &quot;
		elif [ &quot;$major_version&quot; = '4.1' ] || [ &quot;$major_version&quot; = '5.0' ] || [ &quot;$major_version&quot; = '5.1' ] ; then
			cecho &quot;You should enable \&quot;log-queries-not-using-indexes\&quot;&quot;
		fi
		cecho &quot;Then look for non indexed joins in the slow query log.&quot;
		if [ $raise_buffer ] ; then
		cecho &quot;If you are unable to optimize your queries you may want to increase your&quot;
		cecho &quot;join_buffer_size to accommodate larger joins in one pass.&quot;
		printf &quot;\n&quot;
		cecho &quot;Note! This script will still suggest raising the join_buffer_size when&quot; boldred
		cecho &quot;ANY joins not using indexes are found.&quot; boldred
		fi
	fi

	# XXX Add better tests for join_buffer_size XXX #
}

check_tmp_tables () {

## -- Temp Tables -- ##

	cecho &quot;TEMP TABLES&quot; boldblue

	mysql_status \'Created_tmp_tables\' created_tmp_tables
	mysql_status \'Created_tmp_disk_tables\' created_tmp_disk_tables
	mysql_variable \'tmp_table_size\' tmp_table_size
	mysql_variable \'max_heap_table_size\' max_heap_table_size

	if [ $created_tmp_tables -eq 0 ] ; then
		tmp_disk_tables=0
	else
		tmp_disk_tables=$((created_tmp_disk_tables*100/(created_tmp_tables+created_tmp_disk_tables)))
	fi
	human_readable $max_heap_table_size max_heap_table_sizeHR
	cecho &quot;Current max_heap_table_size = $max_heap_table_sizeHR $unit&quot;

	human_readable $tmp_table_size tmp_table_sizeHR
	cecho &quot;Current tmp_table_size = $tmp_table_sizeHR $unit&quot;

	cecho &quot;Of $created_tmp_tables temp tables, $tmp_disk_tables% were created on disk&quot;
	if [ $tmp_table_size -gt $max_heap_table_size ] ; then
		cecho &quot;Effective in-memory tmp_table_size is limited to max_heap_table_size.&quot; yellow
	fi
	if [ $tmp_disk_tables -ge 25 ] ; then
		cecho &quot;Perhaps you should increase your tmp_table_size and/or max_heap_table_size&quot; boldred
		cecho &quot;to reduce the number of disk-based temporary tables&quot; boldred
		cecho &quot;Note! BLOB and TEXT columns are not allow in memory tables.&quot; yellow
		cecho &quot;If you are using these columns raising these values might not impact your &quot; yellow
		cecho  &quot;ratio of on disk temp tables.&quot; yellow
	else
		cecho &quot;Created disk tmp tables ratio seems fine&quot; green
	fi
}

check_open_files () {

## -- Open Files Limit -- ##
	cecho &quot;OPEN FILES LIMIT&quot; boldblue

	mysql_variable \'open_files_limit\' open_files_limit
	mysql_status   \'Open_files\' open_files

	if [ -z $open_files_limit ] || [ $open_files_limit -eq 0 ] ; then
		open_files_limit=$(ulimit -n)
		cant_override=1
	else
		cant_override=0
	fi
	cecho &quot;Current open_files_limit = $open_files_limit files&quot;

	open_files_ratio=$(($open_files*100/$open_files_limit))

	cecho &quot;The open_files_limit should typically be set to at least 2x-3x&quot; yellow
	cecho &quot;that of table_cache if you have heavy MyISAM usage.&quot; yellow
	if [ $open_files_ratio -ge 75 ] ; then
		cecho &quot;You currently have open more than 75% of your open_files_limit&quot; boldred
		if [ $cant_override -eq 1 ] ; then
			cecho &quot;You should set a higer value for ulimit -u in the mysql startup script then restart mysqld&quot; boldred
			cecho &quot;MySQL 3.23 users : This is just a guess based upon the current shell's ulimit -u value&quot; yellow
		elif [ $cant_override -eq 0 ] ; then
			cecho &quot;You should set a higher value for open_files_limit in my.cnf&quot; boldred
		else
			cecho &quot;ERROR can't determine if mysqld override of ulimit is allowed&quot; boldred
			exit 1
		fi
	else
		cecho &quot;Your open_files_limit value seems to be fine&quot; green
	fi

}

check_table_cache () {

## -- Table Cache -- ##

	cecho &quot;TABLE CACHE&quot; boldblue

	mysql_variable \'datadir\' datadir
	mysql_variable \'table_cache\' table_cache

	## /* MySQL +5.1 version of table_cache */ ##
	mysql_variable \'table_open_cache\' table_open_cache
	mysql_variable \'table_definition_cache\' table_definition_cache

	mysql_status \'Open_tables\' open_tables
	mysql_status \'Opened_tables\' opened_tables
	mysql_status \'Open_table_definitions\' open_table_definitions

	table_count=$($mysql -Bse &quot;/*!50000 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' */&quot;)

	if [ -z &quot;$table_count&quot; ] ; then
		if [ &quot;$UID&quot; != &quot;$socket_owner&quot; ] &amp;&amp; [ &quot;$UID&quot; != &quot;0&quot; ] ; then
			cecho &quot;You are not '$socket_owner' or 'root'&quot; red
			cecho &quot;I am unable to determine the table_count!&quot; red
		else
			table_count=$(find $datadir 2&gt;&amp;1 | grep -c .frm$)
		fi
	fi
	if [ $table_open_cache ] ; then
		table_cache=$table_open_cache
	fi

	if [ $opened_tables -ne 0 ] &amp;&amp; [ $table_cache -ne 0 ] ; then
		table_cache_hit_rate=$(($open_tables*100/$opened_tables))
		table_cache_fill=$(($open_tables*100/$table_cache))
	elif [ $opened_tables -eq 0 ] &amp;&amp; [ $table_cache -ne 0 ] ; then
		table_cache_hit_rate=100
		table_cache_fill=$(($open_tables*100/$table_cache))
	else
		cecho &quot;ERROR no table_cache ?!&quot; boldred
		exit 1
	fi
	if [ $table_cache ] &amp;&amp; [ ! $table_open_cache ] ; then
		cecho &quot;Current table_cache value = $table_cache tables&quot;
	fi
	if [ $table_open_cache ] ; then
		cecho &quot;Current table_open_cache = $table_open_cache tables&quot;
		cecho &quot;Current table_definition_cache = $table_definition_cache tables&quot;
	fi
	if [ $table_count ] ; then
	cecho &quot;You have a total of $table_count tables&quot;
	fi

	if  [ $table_cache_fill -lt 95 ] ; then
		cechon &quot;You have &quot;
		cechon &quot;$open_tables &quot; green
		cecho &quot;open tables.&quot;
		cecho &quot;The table_cache value seems to be fine&quot; green
	elif [ $table_cache_hit_rate -le 85 -o  $table_cache_fill -ge 95 ]; then
		cechon &quot;You have &quot;
		cechon &quot;$open_tables &quot; boldred
		cecho &quot;open tables.&quot;
		cechon &quot;Current table_cache hit rate is &quot;
		cecho &quot;$table_cache_hit_rate%&quot; boldred
		cechon &quot;, while &quot;
		cechon &quot;$table_cache_fill% &quot; boldred
		cecho &quot;of your table cache is in use&quot;
		cecho &quot;You should probably increase your table_cache&quot; red
	else
		cechon &quot;Current table_cache hit rate is &quot;
		cechon &quot;$table_cache_hit_rate%&quot; green
		cechon &quot;, while &quot;
		cechon &quot;$table_cache_fill% &quot; green
		cecho &quot;of your table cache is in use&quot;
		cecho &quot;The table cache value seems to be fine&quot; green
	fi
	if [ $table_definition_cache ] &amp;&amp; [ $table_definition_cache -le $table_count ] &amp;&amp; [ $table_count -ge 100 ] ; then
		cecho &quot;You should probably increase your table_definition_cache value.&quot; red
	fi
}

check_table_locking () {

## -- Table Locking -- ##

	cecho &quot;TABLE LOCKING&quot; boldblue

	mysql_status \'Table_locks_waited\' table_locks_waited
	mysql_status \'Table_locks_immediate\' table_locks_immediate
	mysql_variable \'concurrent_insert\' concurrent_insert
	mysql_variable \'low_priority_updates\' low_priority_updates
        if [ &quot;$concurrent_insert&quot; = 'ON' ]; then
                concurrent_insert=1
        elif [ &quot;$concurrent_insert&quot; = 'OFF' ]; then
                concurrent_insert=0
        fi

	cechon &quot;Current Lock Wait ratio = &quot;
	if [ $table_locks_waited -gt 0 ]; then
		immediate_locks_miss_rate=$(($table_locks_immediate/$table_locks_waited))
		cecho &quot;1 : $immediate_locks_miss_rate&quot; red
	else
		immediate_locks_miss_rate=99999 # perfect
		cecho &quot;0 : $questions&quot;
	fi
	if [ $immediate_locks_miss_rate -lt 5000 ] ; then
		cecho &quot;You may benefit from selective use of InnoDB.&quot;
		if [ &quot;$low_priority_updates&quot; = 'OFF' ] ; then
		cecho &quot;If you have long running SELECT's against MyISAM tables and perform&quot;
		cecho &quot;frequent updates consider setting 'low_priority_updates=1'&quot;
		fi
		if [ $concurrent_insert -le 1 ] &amp;&amp; [ &quot;$major_version&quot; = '5.0' -o &quot;$major_version&quot; = '5.1' ] ; then
		cecho &quot;If you have a high concurrency of inserts on Dynamic row-length tables&quot;
		cecho &quot;consider setting 'concurrent_insert=2'.&quot;
		fi
	else
		cecho &quot;Your table locking seems to be fine&quot; green
	fi
}

check_table_scans () {

## -- Table Scans -- ##

	cecho &quot;TABLE SCANS&quot; boldblue

	mysql_status \'Com_select\' com_select
	mysql_status \'Handler_read_rnd_next\' read_rnd_next
	mysql_variable \'read_buffer_size\' read_buffer_size

	if [ -z $read_buffer_size ] ; then
		mysql_variable \'record_buffer\' read_buffer_size
	fi

 	human_readable $read_buffer_size read_buffer_sizeHR
	cecho &quot;Current read_buffer_size = $read_buffer_sizeHR $unit&quot;

	if [ $com_select -gt 0 ] ; then
		full_table_scans=$(($read_rnd_next/$com_select))
		cecho &quot;Current table scan ratio = $full_table_scans : 1&quot;
		if [ $full_table_scans -ge 4000 ] &amp;&amp; [ $read_buffer_size -le 2097152 ] ; then
			cecho &quot;You have a high ratio of sequential access requests to SELECTs&quot; red
			cechon &quot;You may benefit from raising &quot; red
			if [ &quot;$major_version&quot; = '3.23' ] ; then
				cechon &quot;record_buffer &quot; red
			else
				cechon &quot;read_buffer_size &quot; red
			fi
			cecho &quot;and/or improving your use of indexes.&quot; red
		elif [ $read_buffer_size -gt 8388608 ] ; then
			cechon &quot;read_buffer_size is over 8 MB &quot; red
			cecho &quot;there is probably no need for such a large read_buffer&quot; red

		else
			cecho &quot;read_buffer_size seems to be fine&quot; green
		fi
	else
		cecho &quot;read_buffer_size seems to be fine&quot; green
	fi
}

check_innodb_status () {

## -- InnoDB -- ##

	mysql_variable \'have_innodb\' have_innodb

	if [ &quot;$have_innodb&quot; = &quot;YES&quot; ] ; then
		mysql_variable \'innodb_buffer_pool_size\' innodb_buffer_pool_size
		mysql_variable \'innodb_additional_mem_pool_size\' innodb_additional_mem_pool_size
		mysql_variable \'innodb_fast_shutdown\' innodb_fast_shutdown
		mysql_variable \'innodb_flush_log_at_trx_commit\' innodb_flush_log_at_trx_commit
		mysql_variable \'innodb_locks_unsafe_for_binlog\' innodb_locks_unsafe_for_binlog
		mysql_variable \'innodb_log_buffer_size\' innodb_log_buffer_size
		mysql_variable \'innodb_log_file_size\' innodb_log_file_size
		mysql_variable \'innodb_log_files_in_group\' innodb_log_files_in_group
		mysql_variable \'innodb_safe_binlog\' innodb_safe_binlog
		mysql_variable \'innodb_thread_concurrency\' innodb_thread_concurrency

		cecho &quot;INNODB STATUS&quot; boldblue
		innodb_indexes=$($mysql -Bse &quot;/*!50000 SELECT IFNULL(SUM(INDEX_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */&quot;)
		innodb_data=$($mysql -Bse &quot;/*!50000 SELECT IFNULL(SUM(DATA_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */&quot;)

		if [ ! -z &quot;$innodb_indexes&quot; ] ; then

		mysql_status \'Innodb_buffer_pool_pages_data\' innodb_buffer_pool_pages_data
		mysql_status \'Innodb_buffer_pool_pages_misc\' innodb_buffer_pool_pages_misc
		mysql_status \'Innodb_buffer_pool_pages_free\' innodb_buffer_pool_pages_free
		mysql_status \'Innodb_buffer_pool_pages_total\' innodb_buffer_pool_pages_total

		mysql_status \'Innodb_buffer_pool_read_ahead_seq\' innodb_buffer_pool_read_ahead_seq
		mysql_status \'Innodb_buffer_pool_read_requests\' innodb_buffer_pool_read_requests

		mysql_status \'Innodb_os_log_pending_fsyncs\' innodb_os_log_pending_fsyncs
		mysql_status \'Innodb_os_log_pending_writes\'	innodb_os_log_pending_writes
		mysql_status \'Innodb_log_waits\' innodb_log_waits

		mysql_status \'Innodb_row_lock_time\' innodb_row_lock_time
		mysql_status \'Innodb_row_lock_waits\' innodb_row_lock_waits

		human_readable $innodb_indexes innodb_indexesHR
		cecho &quot;Current InnoDB index space = $innodb_indexesHR $unit&quot;
		human_readable $innodb_data innodb_dataHR
		cecho &quot;Current InnoDB data space = $innodb_dataHR $unit&quot;
		percent_innodb_buffer_pool_free=$(($innodb_buffer_pool_pages_free*100/$innodb_buffer_pool_pages_total))
		cecho &quot;Current InnoDB buffer pool free = &quot;$percent_innodb_buffer_pool_free&quot; %&quot;

		else
		cecho &quot;Cannot parse InnoDB stats prior to 5.0.x&quot; red
		$mysql -s -e &quot;SHOW /*!50000 ENGINE */ INNODB STATUS\G&quot;
		fi

		human_readable $innodb_buffer_pool_size innodb_buffer_pool_sizeHR
		cecho &quot;Current innodb_buffer_pool_size = $innodb_buffer_pool_sizeHR $unit&quot;
		cecho &quot;Depending on how much space your innodb indexes take up it may be safe&quot;
		cecho &quot;to increase this value to up to 2 / 3 of total system memory&quot;
	else
		cecho &quot;No InnoDB Support Enabled!&quot; boldred
	fi
}

total_memory_used () {

## -- Total Memory Usage -- ##
	cecho &quot;MEMORY USAGE&quot; boldblue

	mysql_variable \'read_buffer_size\' read_buffer_size
	mysql_variable \'read_rnd_buffer_size\' read_rnd_buffer_size
	mysql_variable \'sort_buffer_size\' sort_buffer_size
	mysql_variable \'thread_stack\' thread_stack
	mysql_variable \'max_connections\' max_connections
	mysql_variable \'join_buffer_size\' join_buffer_size
	mysql_variable \'tmp_table_size\' tmp_table_size
	mysql_variable \'max_heap_table_size\' max_heap_table_size
	mysql_variable \'log_bin\' log_bin
	mysql_status \'Max_used_connections\' max_used_connections

	if [ &quot;$major_version&quot; = &quot;3.23&quot; ] ; then
		mysql_variable \'record_buffer\' read_buffer_size
		mysql_variable \'record_rnd_buffer\' read_rnd_buffer_size
		mysql_variable \'sort_buffer\' sort_buffer_size
	fi

	if [ &quot;$log_bin&quot; = &quot;ON&quot; ] ; then
		mysql_variable \'binlog_cache_size\' binlog_cache_size
	else
		binlog_cache_size=0
	fi

	if [ $max_heap_table_size -le $tmp_table_size ] ; then
		effective_tmp_table_size=$max_heap_table_size
	else
		effective_tmp_table_size=$tmp_table_size
	fi

	per_thread_buffers=$(echo &quot;($read_buffer_size+$read_rnd_buffer_size+$sort_buffer_size+$thread_stack+$join_buffer_size+$binlog_cache_size)*$max_connections&quot; | bc -l)
	per_thread_max_buffers=$(echo &quot;($read_buffer_size+$read_rnd_buffer_size+$sort_buffer_size+$thread_stack+$join_buffer_size+$binlog_cache_size)*$max_used_connections&quot; | bc -l)

        mysql_variable \'innodb_buffer_pool_size\' innodb_buffer_pool_size
        if [ -z $innodb_buffer_pool_size ] ; then
        innodb_buffer_pool_size=0
        fi

        mysql_variable \'innodb_additional_mem_pool_size\' innodb_additional_mem_pool_size
        if [ -z $innodb_additional_mem_pool_size ] ; then
        innodb_additional_mem_pool_size=0
        fi

        mysql_variable \'innodb_log_buffer_size\' innodb_log_buffer_size
        if [ -z $innodb_log_buffer_size ] ; then
        innodb_log_buffer_size=0
        fi

        mysql_variable \'key_buffer_size\' key_buffer_size

        mysql_variable \'query_cache_size\' query_cache_size
        if [ -z $query_cache_size ] ; then
        query_cache_size=0
        fi

	global_buffers=$(echo &quot;$innodb_buffer_pool_size+$innodb_additional_mem_pool_size+$innodb_log_buffer_size+$key_buffer_size+$query_cache_size&quot; | bc -l)

	max_memory=$(echo &quot;$global_buffers+$per_thread_max_buffers&quot; | bc -l)
	total_memory=$(echo &quot;$global_buffers+$per_thread_buffers&quot; | bc -l)

	pct_of_sys_mem=$(echo &quot;scale=0; $total_memory*100/$physical_memory&quot; | bc -l)

	if [ $pct_of_sys_mem -gt 90 ] ; then
		txt_color=boldred
		error=1
	else
		txt_color=
		error=0
	fi

	human_readable $max_memory max_memoryHR
	cecho &quot;Max Memory Ever Allocated : $max_memoryHR $unit&quot; $txt_color
	human_readable $per_thread_buffers per_thread_buffersHR
	cecho &quot;Configured Max Per-thread Buffers : $per_thread_buffersHR $unit&quot; $txt_color
	human_readable $global_buffers global_buffersHR
	cecho &quot;Configured Max Global Buffers : $global_buffersHR $unit&quot; $txt_color
	human_readable $total_memory total_memoryHR
	cecho &quot;Configured Max Memory Limit : $total_memoryHR $unit&quot; $txt_color
#	human_readable $effective_tmp_table_size effective_tmp_table_sizeHR
#	cecho &quot;Plus $effective_tmp_table_sizeHR $unit per temporary table created&quot;
	human_readable $physical_memory physical_memoryHR
	cecho &quot;Physical Memory : $physical_memoryHR $unit&quot; $txt_color
	if [ $error -eq 1 ] ; then
		printf &quot;\n&quot;
		cecho &quot;nMax memory limit exceeds 90% of physical memory&quot; $txt_color
	else
		cecho &quot;Max memory limit seem to be within acceptable norms&quot; green
	fi
	unset txt_color
}

## Required Functions  ##

login_validation () {
	check_for_socket 		# determine the socket location -- 1st login
	check_for_plesk_passwords	# determine the login method -- 2nd login
	check_mysql_login		# determine if mysql is accepting login -- 3rd login
	export major_version=$($mysql -Bse &quot;SELECT SUBSTRING_INDEX(VERSION(), '.', +2)&quot;)
	export mysql_version_num=$($mysql -Bse &quot;SELECT LEFT(REPLACE(SUBSTRING_INDEX(VERSION(), '-', +1), '.', ''),4)&quot; )
}

shared_info () {
	export major_version=$($mysql -Bse &quot;SELECT SUBSTRING_INDEX(VERSION(), '.', +2)&quot;)
	export mysql_version_num=$($mysql -Bse &quot;SELECT LEFT(REPLACE(SUBSTRING_INDEX(VERSION(), '-', +1), '.', ''),4)&quot; )
	mysql_status \'Questions\' questions
#	socket_owner=$(find -L $socket -printf '%u\n')
	socket_owner=$(ls -nH $socket | awk '{ print $3 }')
}

get_system_info () {

    export OS=$(uname)

    # Get information for various UNIXes
    if [ &quot;$OS&quot; = 'Darwin' ]; then
	ps_socket=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }' | head -1)
	found_socks=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }')
        export physical_memory=$(sysctl -n hw.memsize)
	export duflags=''
    elif [ &quot;$OS&quot; = 'FreeBSD' ] || [ &quot;$OS&quot; = 'OpenBSD' ]; then
	## On FreeBSD must be root to locate sockets.
	ps_socket=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }' | head -1)
	found_socks=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }')
        export physical_memory=$(sysctl -n hw.realmem)
	export duflags=''
    elif [ &quot;$OS&quot; = 'Linux' ] ; then
	## Includes SWAP
        ## export physical_memory=$(free -b | grep -v buffers |  awk '{ s += $2 } END { printf(&quot;%.0f\n&quot;, s ) }')
	ps_socket=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }' | head -1)
	found_socks=$(netstat -ln | awk '/mysql(d)?\.sock/ { print $9 }')
	export physical_memory=$(awk '/^MemTotal/ { printf(&quot;%.0f&quot;, $2*1024 ) }' &lt; /proc/meminfo)
	export duflags='-b'
    elif [ &quot;$OS&quot; = 'SunOS' ] ; then
	ps_socket=$(netstat -a | awk '/mysql(d)?.sock/ { print $5 }' | head -1)
	found_socks=$(netstat -a | awk '/mysql(d)?.sock/ { print $5 }')
	export physical_memory=$(prtconf | awk '/^Memory\ size:/ { print $3*1048576 }')
    fi
}

## Optional Components Groups ##

banner_info () {
	shared_info
	print_banner		; echo
	check_mysql_version	; echo
	post_uptime_warning	; echo
}

misc () {
	shared_info
	check_slow_queries	; echo
	check_binary_log	; echo
	check_threads		; echo
	check_used_connections	; echo
	check_innodb_status	; echo
}

memory () {
	shared_info
	total_memory_used	; echo
	check_key_buffer_size	; echo
	check_query_cache	; echo
	check_sort_operations	; echo
	check_join_operations	; echo
}

file () {
	shared_info
	check_open_files	; echo
	check_table_cache	; echo
	check_tmp_tables	; echo
	check_table_scans	; echo
	check_table_locking	; echo
}

all () {
	banner_info
	misc
	memory
	file
}

prompt () {
	prompted='true'
	read -p &quot;Username [anonymous] : &quot; user
	read -rp &quot;Password [&lt;none&gt;] : &quot; pass
	cecho &quot; &quot;
	read -p &quot;Socket [ /var/lib/mysql/mysql.sock ] : &quot; socket
	if [ -z $socket ] ; then
		export socket='/var/lib/mysql/mysql.sock'
	fi

	if [ -z $pass ] ; then
	export mysql=&quot;mysql -S $socket -u$user&quot;
	export mysqladmin=&quot;mysqladmin -S $socket -u$user&quot;
	else
        export mysql=&quot;mysql -S $socket -u$user -p$pass&quot;
        export mysqladmin=&quot;mysqladmin -S $socket -u$user -p$pass&quot;
	fi

	check_for_socket
	check_mysql_login

	if [ $? = 1 ] ; then
		exit 1
	fi
	read -p &quot;Mode to test - banner, file, misc, mem, innodb, [all] : &quot; REPLY
	if [ -z $REPLY ] ; then
		REPLY='all'
	fi
	case $REPLY in
	        banner | BANNER | header | HEADER | head | HEAD)
		banner_info
		;;
		misc | MISC | miscelaneous )
		misc
		;;
        	mem | memory |  MEM | MEMORY )
		memory
		;;
		file | FILE | disk | DISK )
		file
		;;
		innodb | INNODB )
		innodb
		;;
		all | ALL )
		cecho &quot; &quot;
		all
		;;
		* )
		cecho &quot;Invalid Mode!  Valid options are 'banner', 'misc', 'memory', 'file', 'innodb' or 'all'&quot; boldred
		exit 1
		;;
	esac
}

## Address environmental differences ##
get_system_info
# echo $ps_socket

if [ -z &quot;$1&quot; ] ; then
	login_validation
	mode='ALL'
elif [ &quot;$1&quot; = &quot;prompt&quot; ] || [ &quot;$1&quot; = &quot;PROMPT&quot; ] ; then
	mode=$1
elif [ &quot;$1&quot; != &quot;prompt&quot; ] || [ &quot;$1&quot; != &quot;PROMPT&quot; ] ; then
	login_validation
	mode=$1
fi

case $mode in
	all | ALL )
	cecho &quot; &quot;
	all
	;;
	mem | memory |  MEM | MEMORY )
	cecho &quot; &quot;
	memory
	;;
	file | FILE | disk | DISK )
	cecho &quot; &quot;
	file
	;;
	banner | BANNER | header | HEADER | head | HEAD )
	banner_info
	;;
	misc | MISC | miscelaneous )
	cecho &quot; &quot;
	misc
	;;
	innodb | INNODB )
	banner_info
	check_innodb_status ; echo
	;;
	prompt | PROMPT )
	prompt
	;;
	*)
	cecho &quot;usage: $0 [ all | banner | file | innodb | memory | misc | prompt ]&quot; boldred
	exit 1
	;;
esac
</pre></p>
<p>.</p>
<p style="text-align:justify;">
<p style="text-align:justify;"><a title="MySQLTuner :: Script de optimización de MySQl" href="http://mysqltuner.pl">MySQLTuner</a></p>
<p><pre class="brush: perl;">
#!/usr/bin/perl -w
# mysqltuner.pl - Version 1.1.0
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2009 Major Hayden - major@mhtx.net
#
# For the latest updates, please visit http://mysqltuner.com/
# Subversion repository available at http://tools.assembla.com/svn/mysqltuner/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
#
# This project would not be possible without help from:
#   Matthew Montgomery     Paul Kehrer
#   Dave Burgess           Jonathan Hinds
#   Mike Jackson           Nils Breunese
#   Shawn Ashlee           Luuk Vosslamber
#   Ville Skytta           Trent Hornibrook
#   Jason Gill             Mark Imbriaco
#   Greg Eden              Aubin Galinotti
#   Giovanni Bechis        Bill Bradford
#   Ryan Novosielski       Michael Scheidell
#   Blair Christensen      Hans du Plooy
#   Victor Trac            Everett Barnes
#   Tom Krouper            Gary Barrueto
#   Simon Greenaway        Adam Stein
#
# Inspired by Matthew Montgomery's tuning-primer.sh script:
# http://forge.mysql.com/projects/view.php?id=44
#
use strict;
use warnings;
use diagnostics;
use Getopt::Long;

# Set up a few variables for use in the script
my $tunerversion = &quot;1.0.1&quot;;
my (@adjvars, @generalrec);

# Set defaults
my %opt = (
		&quot;nobad&quot; =&gt; 0,
		&quot;nogood&quot; =&gt; 0,
		&quot;noinfo&quot; =&gt; 0,
		&quot;nocolor&quot; =&gt; 0,
		&quot;forcemem&quot; =&gt; 0,
		&quot;forceswap&quot; =&gt; 0,
		&quot;host&quot; =&gt; 0,
		&quot;socket&quot; =&gt; 0,
		&quot;port&quot; =&gt; 0,
		&quot;user&quot; =&gt; 0,
		&quot;pass&quot; =&gt; 0,
		&quot;skipsize&quot; =&gt; 0,
		&quot;checkversion&quot; =&gt; 0,
	);

# Gather the options from the command line
GetOptions(\%opt,
		'nobad',
		'nogood',
		'noinfo',
		'nocolor',
		'forcemem=i',
		'forceswap=i',
		'host=s',
		'socket=s',
		'port=i',
		'user=s',
		'pass=s',
		'skipsize',
		'checkversion',
		'help',
	);

if (defined $opt{'help'} &amp;&amp; $opt{'help'} == 1) { usage(); }

sub usage {
	# Shown with --help option passed
	print &quot;\n&quot;.
		&quot;   MySQLTuner $tunerversion - MySQL High Performance Tuning Script\n&quot;.
		&quot;   Bug reports, feature requests, and downloads at http://mysqltuner.com/\n&quot;.
		&quot;   Maintained by Major Hayden (major\@mhtx.net) - Licensed under GPL\n&quot;.
		&quot;\n&quot;.
		&quot;   Important Usage Guidelines:\n&quot;.
		&quot;      To run the script with the default options, run the script without arguments\n&quot;.
		&quot;      Allow MySQL server to run for at least 24-48 hours before trusting suggestions\n&quot;.
		&quot;      Some routines may require root level privileges (script will provide warnings)\n&quot;.
		&quot;      You must provide the remote server's total memory when connecting to other servers\n&quot;.
		&quot;\n&quot;.
		&quot;   Connection and Authentication\n&quot;.
		&quot;      --host &lt;hostname&gt;    Connect to a remote host to perform tests (default: localhost)\n&quot;.
		&quot;      --socket &lt;socket&gt;    Use a different socket for a local connection\n&quot;.
		&quot;      --port &lt;port&gt;        Port to use for connection (default: 3306)\n&quot;.
		&quot;      --user &lt;username&gt;    Username to use for authentication\n&quot;.
		&quot;      --pass &lt;password&gt;    Password to use for authentication\n&quot;.
		&quot;\n&quot;.
		&quot;   Performance and Reporting Options\n&quot;.
		&quot;      --skipsize           Don't enumerate tables and their types/sizes (default: on)\n&quot;.
		&quot;                             (Recommended for servers with many tables)\n&quot;.
		&quot;      --checkversion       Check for updates to MySQLTuner (default: don't check)\n&quot;.
		&quot;      --forcemem &lt;size&gt;    Amount of RAM installed in megabytes\n&quot;.
		&quot;      --forceswap &lt;size&gt;   Amount of swap memory configured in megabytes\n&quot;.
		&quot;\n&quot;.
		&quot;   Output Options:\n&quot;.
		&quot;      --nogood             Remove OK responses\n&quot;.
		&quot;      --nobad              Remove negative/suggestion responses\n&quot;.
		&quot;      --noinfo             Remove informational responses\n&quot;.
		&quot;      --nocolor            Don't print output in color\n&quot;.
		&quot;\n&quot;;
	exit;
}

# Setting up the colors for the print styles
my $good = ($opt{nocolor} == 0)? &quot;[\e[0;32mOK\e[0m]&quot; : &quot;[OK]&quot; ;
my $bad = ($opt{nocolor} == 0)? &quot;[\e[0;31m!!\e[0m]&quot; : &quot;[!!]&quot; ;
my $info = ($opt{nocolor} == 0)? &quot;[\e[0;34m--\e[0m]&quot; : &quot;[--]&quot; ;

# Functions that handle the print styles
sub goodprint { print $good.&quot; &quot;.$_[0] unless ($opt{nogood} == 1); }
sub infoprint { print $info.&quot; &quot;.$_[0] unless ($opt{noinfo} == 1); }
sub badprint { print $bad.&quot; &quot;.$_[0] unless ($opt{nobad} == 1); }
sub redwrap { return ($opt{nocolor} == 0)? &quot;\e[0;31m&quot;.$_[0].&quot;\e[0m&quot; : $_[0] ; }
sub greenwrap { return ($opt{nocolor} == 0)? &quot;\e[0;32m&quot;.$_[0].&quot;\e[0m&quot; : $_[0] ; }

# Calculates the parameter passed in bytes, and then rounds it to one decimal place
sub hr_bytes {
	my $num = shift;
	if ($num &gt;= (1024**3)) { #GB
		return sprintf(&quot;%.1f&quot;,($num/(1024**3))).&quot;G&quot;;
	} elsif ($num &gt;= (1024**2)) { #MB
		return sprintf(&quot;%.1f&quot;,($num/(1024**2))).&quot;M&quot;;
	} elsif ($num &gt;= 1024) { #KB
		return sprintf(&quot;%.1f&quot;,($num/1024)).&quot;K&quot;;
	} else {
		return $num.&quot;B&quot;;
	}
}

# Calculates the parameter passed in bytes, and then rounds it to the nearest integer
sub hr_bytes_rnd {
	my $num = shift;
	if ($num &gt;= (1024**3)) { #GB
		return int(($num/(1024**3))).&quot;G&quot;;
	} elsif ($num &gt;= (1024**2)) { #MB
		return int(($num/(1024**2))).&quot;M&quot;;
	} elsif ($num &gt;= 1024) { #KB
		return int(($num/1024)).&quot;K&quot;;
	} else {
		return $num.&quot;B&quot;;
	}
}

# Calculates the parameter passed to the nearest power of 1000, then rounds it to the nearest integer
sub hr_num {
	my $num = shift;
	if ($num &gt;= (1000**3)) { # Billions
		return int(($num/(1000**3))).&quot;B&quot;;
	} elsif ($num &gt;= (1000**2)) { # Millions
		return int(($num/(1000**2))).&quot;M&quot;;
	} elsif ($num &gt;= 1000) { # Thousands
		return int(($num/1000)).&quot;K&quot;;
	} else {
		return $num;
	}
}

# Calculates uptime to display in a more attractive form
sub pretty_uptime {
	my $uptime = shift;
	my $seconds = $uptime % 60;
	my $minutes = int(($uptime % 3600) / 60);
	my $hours = int(($uptime % 86400) / (3600));
	my $days = int($uptime / (86400));
	my $uptimestring;
	if ($days &gt; 0) {
		$uptimestring = &quot;${days}d ${hours}h ${minutes}m ${seconds}s&quot;;
	} elsif ($hours &gt; 0) {
		$uptimestring = &quot;${hours}h ${minutes}m ${seconds}s&quot;;
	} elsif ($minutes &gt; 0) {
		$uptimestring = &quot;${minutes}m ${seconds}s&quot;;
	} else {
		$uptimestring = &quot;${seconds}s&quot;;
	}
	return $uptimestring;
}

# Retrieves the memory installed on this machine
my ($physical_memory,$swap_memory,$duflags);
sub os_setup {
	sub memerror {
		badprint &quot;Unable to determine total memory/swap; use '--forcemem' and '--forceswap'\n&quot;;
		exit;
	}
	my $os = `uname`;
	$duflags = ($os =~ /Linux/) ? '-b' : '';
	if ($opt{'forcemem'} &gt; 0) {
		$physical_memory = $opt{'forcemem'} * 1048576;
		infoprint &quot;Assuming $opt{'forcemem'} MB of physical memory\n&quot;;
		if ($opt{'forceswap'} &gt; 0) {
			$swap_memory = $opt{'forceswap'} * 1048576;
			infoprint &quot;Assuming $opt{'forceswap'} MB of swap space\n&quot;;
		} else {
			$swap_memory = 0;
			badprint &quot;Assuming 0 MB of swap space (use --forceswap to specify)\n&quot;;
		}
	} else {
		if ($os =~ /Linux/) {
			$physical_memory = `free -b | grep Mem | awk '{print \$2}'` or memerror;
			$swap_memory = `free -b | grep Swap | awk '{print \$2}'` or memerror;
		} elsif ($os =~ /Darwin/) {
			$physical_memory = `sysctl -n hw.memsize` or memerror;
			$swap_memory = `sysctl -n vm.swapusage | awk '{print \$3}' | sed 's/\..*\$//'` or memerror;
		} elsif ($os =~ /NetBSD|OpenBSD/) {
			$physical_memory = `sysctl -n hw.physmem` or memerror;
			if ($physical_memory &lt; 0) {
				$physical_memory = `sysctl -n hw.physmem64` or memerror;
			}
			$swap_memory = `swapctl -l | grep '^/' | awk '{ s+= \$2 } END { print s }'` or memerror;
		} elsif ($os =~ /BSD/) {
			$physical_memory = `sysctl -n hw.realmem`;
			$swap_memory = `swapinfo | grep '^/' | awk '{ s+= \$2 } END { print s }'`;
		} elsif ($os =~ /SunOS/) {
			$physical_memory = `/usr/sbin/prtconf | grep Memory | cut -f 3 -d ' '` or memerror;
			chomp($physical_memory);
			$physical_memory = $physical_memory*1024*1024;
		}
	}
	chomp($physical_memory);
}

# Checks to see if a MySQL login is possible
my ($mysqllogin,$doremote,$remotestring);
sub mysql_setup {
	$doremote = 0;
	$remotestring = '';
	my $command = `which mysqladmin`;
	chomp($command);
	if (! -e $command) {
		badprint &quot;Unable to find mysqladmin in your \$PATH.  Is MySQL installed?\n&quot;;
		exit;
	}
	# Are we being asked to connect via a socket?
	if ($opt{socket} ne 0) {
		$remotestring = &quot; -S $opt{socket}&quot;;
	}
	# Are we being asked to connect to a remote server?
	if ($opt{host} ne 0) {
		chomp($opt{host});
		$opt{port} = ($opt{port} eq 0)? 3306 : $opt{port} ;
		# If we're doing a remote connection, but forcemem wasn't specified, we need to exit
		if ($opt{'forcemem'} eq 0) {
			badprint &quot;The --forcemem option is required for remote connections\n&quot;;
			exit;
		}
		infoprint &quot;Performing tests on $opt{host}:$opt{port}\n&quot;;
		$remotestring = &quot; -h $opt{host} -P $opt{port}&quot;;
		$doremote = 1;
	}
	# Did we already get a username and password passed on the command line?
	if ($opt{user} ne 0 and $opt{pass} ne 0) {
		$mysqllogin = &quot;-u $opt{user} -p'$opt{pass}'&quot;.$remotestring;
		my $loginstatus = `mysqladmin ping $mysqllogin 2&gt;&amp;1`;
		if ($loginstatus =~ /mysqld is alive/) {
			goodprint &quot;Logged in using credentials passed on the command line\n&quot;;
			return 1;
		} else {
			badprint &quot;Attempted to use login credentials, but they were invalid\n&quot;;
			exit 0;
		}
	}
	if ( -r &quot;/etc/psa/.psa.shadow&quot; and $doremote == 0 ) {
		# It's a Plesk box, use the available credentials
		$mysqllogin = &quot;-u admin -p`cat /etc/psa/.psa.shadow`&quot;;
		my $loginstatus = `mysqladmin ping $mysqllogin 2&gt;&amp;1`;
		unless ($loginstatus =~ /mysqld is alive/) {
			badprint &quot;Attempted to use login credentials from Plesk, but they failed.\n&quot;;
			exit 0;
		}
	} else {
		# It's not Plesk, we should try a login
		my $loginstatus = `mysqladmin $remotestring ping 2&gt;&amp;1`;
		if ($loginstatus =~ /mysqld is alive/) {
			# Login went just fine
			$mysqllogin = &quot; $remotestring &quot;;
			# Did this go well because of a .my.cnf file or is there no password set?
			my $userpath = `printenv HOME`;
			if (length($userpath) &gt; 0) {
				chomp($userpath);
			}
			unless ( -e &quot;${userpath}/.my.cnf&quot; ) {
				badprint &quot;Successfully authenticated with no password - SECURITY RISK!\n&quot;;
			}
			return 1;
		} else {
			print STDERR &quot;Please enter your MySQL administrative login: &quot;;
			my $name = &lt;&gt;;
			print STDERR &quot;Please enter your MySQL administrative password: &quot;;
			system(&quot;stty -echo&quot;);
			my $password = &lt;&gt;;
			system(&quot;stty echo&quot;);
			chomp($password);
			chomp($name);
			$mysqllogin = &quot;-u $name&quot;;
			if (length($password) &gt; 0) {
				$mysqllogin .= &quot; -p'$password'&quot;;
			}
			$mysqllogin .= $remotestring;
			my $loginstatus = `mysqladmin ping $mysqllogin 2&gt;&amp;1`;
			if ($loginstatus =~ /mysqld is alive/) {
				print STDERR &quot;\n&quot;;
				if (! length($password)) {
					# Did this go well because of a .my.cnf file or is there no password set?
					my $userpath = `ls -d ~`;
					chomp($userpath);
					unless ( -e &quot;$userpath/.my.cnf&quot; ) {
						badprint &quot;Successfully authenticated with no password - SECURITY RISK!\n&quot;;
					}
				}
				return 1;
			} else {
				print &quot;\n&quot;.$bad.&quot; Attempted to use login credentials, but they were invalid.\n&quot;;
				exit 0;
			}
			exit 0;
		}
	}
}

# Populates all of the variable and status hashes
my (%mystat,%myvar,$dummyselect);
sub get_all_vars {
	# We need to initiate at least one query so that our data is useable
	$dummyselect = `mysql $mysqllogin -Bse &quot;SELECT VERSION();&quot;`;
	my @mysqlvarlist = `mysql $mysqllogin -Bse &quot;SHOW /*!50000 GLOBAL */ VARIABLES;&quot;`;
	foreach my $line (@mysqlvarlist) {
		$line =~ /([a-zA-Z_]*)\s*(.*)/;
		$myvar{$1} = $2;
	}
	my @mysqlstatlist = `mysql $mysqllogin -Bse &quot;SHOW /*!50000 GLOBAL */ STATUS;&quot;`;
	foreach my $line (@mysqlstatlist) {
		$line =~ /([a-zA-Z_]*)\s*(.*)/;
		$mystat{$1} = $2;
	}
}

# Checks for updates to MySQLTuner
sub validate_tuner_version {
	print &quot;\n-------- General Statistics --------------------------------------------------\n&quot;;
	if ($opt{checkversion} eq 0) {
		infoprint &quot;Skipped version check for MySQLTuner script\n&quot;;
		return;
	}
	my $update;
	my $url = &quot;http://mysqltuner.com/versioncheck.php?v=$tunerversion&quot;;
	if (-e &quot;/usr/bin/curl&quot;) {
		$update = `/usr/bin/curl --connect-timeout 5 '$url' 2&gt;/dev/null`;
		chomp($update);
	} elsif (-e &quot;/usr/bin/wget&quot;) {
		$update = `/usr/bin/wget -e timestamping=off -T 5 -O - '$url' 2&gt;/dev/null`;
		chomp($update);
	}
	if ($update eq 1) {
		badprint &quot;There is a new version of MySQLTuner available\n&quot;;
	} elsif ($update eq 0) {
		goodprint &quot;You have the latest version of MySQLTuner\n&quot;;
	} else {
		infoprint &quot;Unable to check for the latest MySQLTuner version\n&quot;;
	}
}

# Checks for supported or EOL'ed MySQL versions
my ($mysqlvermajor,$mysqlverminor);
sub validate_mysql_version {
	($mysqlvermajor,$mysqlverminor) = $myvar{'version'} =~ /(\d)\.(\d)/;
	if ($mysqlvermajor &lt; 5) {
		badprint &quot;Your MySQL version &quot;.$myvar{'version'}.&quot; is EOL software!  Upgrade soon!\n&quot;;
	} elsif ($mysqlvermajor == 5) {
		goodprint &quot;Currently running supported MySQL version &quot;.$myvar{'version'}.&quot;\n&quot;;
	} else {
		badprint &quot;Currently running unsupported MySQL version &quot;.$myvar{'version'}.&quot;\n&quot;;
	}
}

# Checks for 32-bit boxes with more than 2GB of RAM
my ($arch);
sub check_architecture {
	if ($doremote eq 1) { return; }
	if (`uname` =~ /SunOS/ &amp;&amp; `isainfo -b` =~ /64/) {
		$arch = 64;
		goodprint &quot;Operating on 64-bit architecture\n&quot;;
	} elsif (`uname` !~ /SunOS/ &amp;&amp; `uname -m` =~ /64/) {
		$arch = 64;
		goodprint &quot;Operating on 64-bit architecture\n&quot;;
	} else {
		$arch = 32;
		if ($physical_memory &gt; 2147483648) {
			badprint &quot;Switch to 64-bit OS - MySQL cannot currently use all of your RAM\n&quot;;
		} else {
			goodprint &quot;Operating on 32-bit architecture with less than 2GB RAM\n&quot;;
		}
	}
}

# Start up a ton of storage engine counts/statistics
my (%enginestats,%enginecount,$fragtables);
sub check_storage_engines {
	if ($opt{skipsize} eq 1) {
		print &quot;\n-------- Storage Engine Statistics -------------------------------------------\n&quot;;
		infoprint &quot;Skipped due to --skipsize option\n&quot;;
		return;
	}
	print &quot;\n-------- Storage Engine Statistics -------------------------------------------\n&quot;;
	infoprint &quot;Status: &quot;;
	my $engines;
	$engines .= (defined $myvar{'have_archive'} &amp;&amp; $myvar{'have_archive'} eq &quot;YES&quot;)? greenwrap &quot;+Archive &quot; : redwrap &quot;-Archive &quot; ;
	$engines .= (defined $myvar{'have_bdb'} &amp;&amp; $myvar{'have_bdb'} eq &quot;YES&quot;)? greenwrap &quot;+BDB &quot; : redwrap &quot;-BDB &quot; ;
	$engines .= (defined $myvar{'have_federated'} &amp;&amp; $myvar{'have_federated'} eq &quot;YES&quot;)? greenwrap &quot;+Federated &quot; : redwrap &quot;-Federated &quot; ;
	$engines .= (defined $myvar{'have_innodb'} &amp;&amp; $myvar{'have_innodb'} eq &quot;YES&quot;)? greenwrap &quot;+InnoDB &quot; : redwrap &quot;-InnoDB &quot; ;
	$engines .= (defined $myvar{'have_isam'} &amp;&amp; $myvar{'have_isam'} eq &quot;YES&quot;)? greenwrap &quot;+ISAM &quot; : redwrap &quot;-ISAM &quot; ;
	$engines .= (defined $myvar{'have_ndbcluster'} &amp;&amp; $myvar{'have_ndbcluster'} eq &quot;YES&quot;)? greenwrap &quot;+NDBCluster &quot; : redwrap &quot;-NDBCluster &quot; ;
	print &quot;$engines\n&quot;;
	if ($mysqlvermajor &gt;= 5) {
		# MySQL 5 servers can have table sizes calculated quickly from information schema
		my @templist = `mysql $mysqllogin -Bse &quot;SELECT ENGINE,SUM(DATA_LENGTH),COUNT(ENGINE) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;&quot;`;
		foreach my $line (@templist) {
			my ($engine,$size,$count);
			($engine,$size,$count) = $line =~ /([a-zA-Z_]*)\s+(\d+)\s+(\d+)/;
			if (!defined($size)) { next; }
			$enginestats{$engine} = $size;
			$enginecount{$engine} = $count;
		}
		$fragtables = `mysql $mysqllogin -Bse &quot;SELECT COUNT(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free &gt; 0 AND NOT ENGINE='MEMORY';&quot;`;
		chomp($fragtables);
	} else {
		# MySQL &lt; 5 servers take a lot of work to get table sizes
		my @tblist;
		# Now we build a database list, and loop through it to get storage engine stats for tables
		my @dblist = `mysql $mysqllogin -Bse &quot;SHOW DATABASES&quot;`;
		foreach my $db (@dblist) {
			chomp($db);
			if ($db eq &quot;information_schema&quot;) { next; }
			if ($mysqlvermajor == 3 || ($mysqlvermajor == 4 &amp;&amp; $mysqlverminor == 0)) {
				# MySQL 3.23/4.0 keeps Data_Length in the 6th column
				push (@tblist,`mysql $mysqllogin -Bse &quot;SHOW TABLE STATUS FROM \\\`$db\\\`&quot; | awk '{print \$2,\$6,\$9}'`);
			} else {
				# MySQL 4.1+ keeps Data_Length in the 7th column
				push (@tblist,`mysql $mysqllogin -Bse &quot;SHOW TABLE STATUS FROM \\\`$db\\\`&quot; | awk '{print \$2,\$7,\$10}'`);
			}
		}
		# Parse through the table list to generate storage engine counts/statistics
		$fragtables = 0;
		foreach my $line (@tblist) {
			chomp($line);
			$line =~ /([a-zA-Z_]*)\s+(\d+)\s+(\d+)/;
			my $engine = $1;
			my $size = $2;
			my $datafree = $3;
			if ($size !~ /^\d+$/) { $size = 0; }
			if (defined $enginestats{$engine}) {
				$enginestats{$engine} += $size;
				$enginecount{$engine} += 1;
			} else {
				$enginestats{$engine} = $size;
				$enginecount{$engine} = 1;
			}
			if ($datafree &gt; 0) {
				$fragtables++;
			}
		}
	}
	while (my ($engine,$size) = each(%enginestats)) {
		infoprint &quot;Data in $engine tables: &quot;.hr_bytes_rnd($size).&quot; (Tables: &quot;.$enginecount{$engine}.&quot;)&quot;.&quot;\n&quot;;
	}
	# If the storage engine isn't being used, recommend it to be disabled
	if (!defined $enginestats{'InnoDB'} &amp;&amp; defined $myvar{'have_innodb'} &amp;&amp; $myvar{'have_innodb'} eq &quot;YES&quot;) {
		badprint &quot;InnoDB is enabled but isn't being used\n&quot;;
		push(@generalrec,&quot;Add skip-innodb to MySQL configuration to disable InnoDB&quot;);
	}
	if (!defined $enginestats{'BerkeleyDB'} &amp;&amp; defined $myvar{'have_bdb'} &amp;&amp; $myvar{'have_bdb'} eq &quot;YES&quot;) {
		badprint &quot;BDB is enabled but isn't being used\n&quot;;
		push(@generalrec,&quot;Add skip-bdb to MySQL configuration to disable BDB&quot;);
	}
	if (!defined $enginestats{'ISAM'} &amp;&amp; defined $myvar{'have_isam'} &amp;&amp; $myvar{'have_isam'} eq &quot;YES&quot;) {
		badprint &quot;ISAM is enabled but isn't being used\n&quot;;
		push(@generalrec,&quot;Add skip-isam to MySQL configuration to disable ISAM (MySQL &gt; 4.1.0)&quot;);
	}
	# Fragmented tables
	if ($fragtables &gt; 0) {
		badprint &quot;Total fragmented tables: $fragtables\n&quot;;
		push(@generalrec,&quot;Run OPTIMIZE TABLE to defragment tables for better performance&quot;);
	} else {
		goodprint &quot;Total fragmented tables: $fragtables\n&quot;;
	}
}

my %mycalc;
sub calculations {
	if ($mystat{'Questions'} &lt; 1) {
		badprint &quot;Your server has not answered any queries - cannot continue...&quot;;
		exit 0;
	}
	# Per-thread memory
	if ($mysqlvermajor &gt; 3) {
		$mycalc{'per_thread_buffers'} = $myvar{'read_buffer_size'} + $myvar{'read_rnd_buffer_size'} + $myvar{'sort_buffer_size'} + $myvar{'thread_stack'} + $myvar{'join_buffer_size'};
	} else {
		$mycalc{'per_thread_buffers'} = $myvar{'record_buffer'} + $myvar{'record_rnd_buffer'} + $myvar{'sort_buffer'} + $myvar{'thread_stack'} + $myvar{'join_buffer_size'};
	}
	$mycalc{'total_per_thread_buffers'} = $mycalc{'per_thread_buffers'} * $myvar{'max_connections'};
	$mycalc{'max_total_per_thread_buffers'} = $mycalc{'per_thread_buffers'} * $mystat{'Max_used_connections'};

	# Server-wide memory
	$mycalc{'max_tmp_table_size'} = ($myvar{'tmp_table_size'} &gt; $myvar{'max_heap_table_size'}) ? $myvar{'max_heap_table_size'} : $myvar{'tmp_table_size'} ;
	$mycalc{'server_buffers'} = $myvar{'key_buffer_size'} + $mycalc{'max_tmp_table_size'};
	$mycalc{'server_buffers'} += (defined $myvar{'innodb_buffer_pool_size'}) ? $myvar{'innodb_buffer_pool_size'} : 0 ;
	$mycalc{'server_buffers'} += (defined $myvar{'innodb_additional_mem_pool_size'}) ? $myvar{'innodb_additional_mem_pool_size'} : 0 ;
	$mycalc{'server_buffers'} += (defined $myvar{'innodb_log_buffer_size'}) ? $myvar{'innodb_log_buffer_size'} : 0 ;
	$mycalc{'server_buffers'} += (defined $myvar{'query_cache_size'}) ? $myvar{'query_cache_size'} : 0 ;

	# Global memory
	$mycalc{'max_used_memory'} = $mycalc{'server_buffers'} + $mycalc{&quot;max_total_per_thread_buffers&quot;};
	$mycalc{'total_possible_used_memory'} = $mycalc{'server_buffers'} + $mycalc{'total_per_thread_buffers'};
	$mycalc{'pct_physical_memory'} = int(($mycalc{'total_possible_used_memory'} * 100) / $physical_memory);

	# Slow queries
	$mycalc{'pct_slow_queries'} = int(($mystat{'Slow_queries'}/$mystat{'Questions'}) * 100);

	# Connections
	$mycalc{'pct_connections_used'} = int(($mystat{'Max_used_connections'}/$myvar{'max_connections'}) * 100);
	$mycalc{'pct_connections_used'} = ($mycalc{'pct_connections_used'} &gt; 100) ? 100 : $mycalc{'pct_connections_used'} ;

	# Key buffers
	if ($mysqlvermajor &gt; 3 &amp;&amp; !($mysqlvermajor == 4 &amp;&amp; $mysqlverminor == 0)) {
		$mycalc{'pct_key_buffer_used'} = sprintf(&quot;%.1f&quot;,(1 - (($mystat{'Key_blocks_unused'} * $myvar{'key_cache_block_size'}) / $myvar{'key_buffer_size'})) * 100);
	}
	if ($mystat{'Key_read_requests'} &gt; 0) {
		$mycalc{'pct_keys_from_mem'} = sprintf(&quot;%.1f&quot;,(100 - (($mystat{'Key_reads'} / $mystat{'Key_read_requests'}) * 100)));
	} else {
	    $mycalc{'pct_keys_from_mem'} = 0;
	}
	if ($doremote eq 0 and $mysqlvermajor &lt; 5) {
		$mycalc{'total_myisam_indexes'} = `find $myvar{'datadir'} -name '*.MYI' 2&gt;&amp;1 | xargs du -L $duflags '{}' 2&gt;&amp;1 | awk '{ s += \$1 } END { printf (\&quot;%d\&quot;,s) }'`;
	} elsif ($mysqlvermajor &gt;= 5) {
		$mycalc{'total_myisam_indexes'} = `mysql $mysqllogin -Bse &quot;SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'MyISAM';&quot;`;
	}
	if (defined $mycalc{'total_myisam_indexes'} and $mycalc{'total_myisam_indexes'} =~ /^0\n$/) {
		$mycalc{'total_myisam_indexes'} = &quot;fail&quot;;
	} elsif (defined $mycalc{'total_myisam_indexes'}) {
		chomp($mycalc{'total_myisam_indexes'});
	}

	# Query cache
	if ($mysqlvermajor &gt; 3) {
		$mycalc{'query_cache_efficiency'} = sprintf(&quot;%.1f&quot;,($mystat{'Qcache_hits'} / ($mystat{'Com_select'} + $mystat{'Qcache_hits'})) * 100);
		if ($myvar{'query_cache_size'}) {
			$mycalc{'pct_query_cache_used'} = sprintf(&quot;%.1f&quot;,100 - ($mystat{'Qcache_free_memory'} / $myvar{'query_cache_size'}) * 100);
		}
	if ($mystat{'Qcache_lowmem_prunes'} == 0) {
			$mycalc{'query_cache_prunes_per_day'} = 0;
		} else {
			$mycalc{'query_cache_prunes_per_day'} = int($mystat{'Qcache_lowmem_prunes'} / ($mystat{'Uptime'}/86400));
		}
	}

	# Sorting
	$mycalc{'total_sorts'} = $mystat{'Sort_scan'} + $mystat{'Sort_range'};
	if ($mycalc{'total_sorts'} &gt; 0) {
		$mycalc{'pct_temp_sort_table'} = int(($mystat{'Sort_merge_passes'} / $mycalc{'total_sorts'}) * 100);
	}

	# Joins
	$mycalc{'joins_without_indexes'} = $mystat{'Select_range_check'} + $mystat{'Select_full_join'};
	$mycalc{'joins_without_indexes_per_day'} = int($mycalc{'joins_without_indexes'} / ($mystat{'Uptime'}/86400));

	# Temporary tables
	if ($mystat{'Created_tmp_tables'} &gt; 0) {
		if ($mystat{'Created_tmp_disk_tables'} &gt; 0) {
			$mycalc{'pct_temp_disk'} = int(($mystat{'Created_tmp_disk_tables'} / ($mystat{'Created_tmp_tables'} + $mystat{'Created_tmp_disk_tables'})) * 100);
		} else {
			$mycalc{'pct_temp_disk'} = 0;
		}
	}

	# Table cache
	if ($mystat{'Opened_tables'} &gt; 0) {
		$mycalc{'table_cache_hit_rate'} = int($mystat{'Open_tables'}*100/$mystat{'Opened_tables'});
	} else {
		$mycalc{'table_cache_hit_rate'} = 100;
	}

	# Open files
	if ($myvar{'open_files_limit'} &gt; 0) {
		$mycalc{'pct_files_open'} = int($mystat{'Open_files'}*100/$myvar{'open_files_limit'});
	}

	# Table locks
	if ($mystat{'Table_locks_immediate'} &gt; 0) {
		if ($mystat{'Table_locks_waited'} == 0) {
			$mycalc{'pct_table_locks_immediate'} = 100;
		} else {
			$mycalc{'pct_table_locks_immediate'} = int($mystat{'Table_locks_immediate'}*100/($mystat{'Table_locks_waited'} + $mystat{'Table_locks_immediate'}));
		}
	}

	# Thread cache
	$mycalc{'thread_cache_hit_rate'} = int(100 - (($mystat{'Threads_created'} / $mystat{'Connections'}) * 100));

	# Other
	if ($mystat{'Connections'} &gt; 0) {
		$mycalc{'pct_aborted_connections'} = int(($mystat{'Aborted_connects'}/$mystat{'Connections'}) * 100);
	}
	if ($mystat{'Questions'} &gt; 0) {
		$mycalc{'total_reads'} = $mystat{'Com_select'};
		$mycalc{'total_writes'} = $mystat{'Com_delete'} + $mystat{'Com_insert'} + $mystat{'Com_update'} + $mystat{'Com_replace'};
		if ($mycalc{'total_reads'} == 0) {
			$mycalc{'pct_reads'} = 0;
			$mycalc{'pct_writes'} = 100;
		} else {
			$mycalc{'pct_reads'} = int(($mycalc{'total_reads'}/($mycalc{'total_reads'}+$mycalc{'total_writes'})) * 100);
			$mycalc{'pct_writes'} = 100-$mycalc{'pct_reads'};
		}
	}

	# InnoDB
	if ($myvar{'have_innodb'} eq &quot;YES&quot;) {
		$mycalc{'innodb_log_size_pct'} = ($myvar{'innodb_log_file_size'} * 100 / $myvar{'innodb_buffer_pool_size'});
	}
}

sub mysql_stats {
	print &quot;\n-------- Performance Metrics -------------------------------------------------\n&quot;;
	# Show uptime, queries per second, connections, traffic stats
	my $qps;
	if ($mystat{'Uptime'} &gt; 0) { $qps = sprintf(&quot;%.3f&quot;,$mystat{'Questions'}/$mystat{'Uptime'}); }
	if ($mystat{'Uptime'} &lt; 86400) { push(@generalrec,&quot;MySQL started within last 24 hours - recommendations may be inaccurate&quot;); }
	infoprint &quot;Up for: &quot;.pretty_uptime($mystat{'Uptime'}).&quot; (&quot;.hr_num($mystat{'Questions'}).
		&quot; q [&quot;.hr_num($qps).&quot; qps], &quot;.hr_num($mystat{'Connections'}).&quot; conn,&quot;.
		&quot; TX: &quot;.hr_num($mystat{'Bytes_sent'}).&quot;, RX: &quot;.hr_num($mystat{'Bytes_received'}).&quot;)\n&quot;;
	infoprint &quot;Reads / Writes: &quot;.$mycalc{'pct_reads'}.&quot;% / &quot;.$mycalc{'pct_writes'}.&quot;%\n&quot;;

	# Memory usage
	infoprint &quot;Total buffers: &quot;.hr_bytes($mycalc{'server_buffers'}).&quot; global + &quot;.hr_bytes($mycalc{'per_thread_buffers'}).&quot; per thread ($myvar{'max_connections'} max threads)\n&quot;;
	if ($mycalc{'total_possible_used_memory'} &gt; 2*1024*1024*1024 &amp;&amp; $arch eq 32) {
		badprint &quot;Allocating &gt; 2GB RAM on 32-bit systems can cause system instability\n&quot;;
		badprint &quot;Maximum possible memory usage: &quot;.hr_bytes($mycalc{'total_possible_used_memory'}).&quot; ($mycalc{'pct_physical_memory'}% of installed RAM)\n&quot;;
	} elsif ($mycalc{'pct_physical_memory'} &gt; 85) {
		badprint &quot;Maximum possible memory usage: &quot;.hr_bytes($mycalc{'total_possible_used_memory'}).&quot; ($mycalc{'pct_physical_memory'}% of installed RAM)\n&quot;;
		push(@generalrec,&quot;Reduce your overall MySQL memory footprint for system stability&quot;);
	} else {
		goodprint &quot;Maximum possible memory usage: &quot;.hr_bytes($mycalc{'total_possible_used_memory'}).&quot; ($mycalc{'pct_physical_memory'}% of installed RAM)\n&quot;;
	}

	# Slow queries
	if ($mycalc{'pct_slow_queries'} &gt; 5) {
		badprint &quot;Slow queries: $mycalc{'pct_slow_queries'}% (&quot;.hr_num($mystat{'Slow_queries'}).&quot;/&quot;.hr_num($mystat{'Questions'}).&quot;)\n&quot;;
	} else {
		goodprint &quot;Slow queries: $mycalc{'pct_slow_queries'}% (&quot;.hr_num($mystat{'Slow_queries'}).&quot;/&quot;.hr_num($mystat{'Questions'}).&quot;)\n&quot;;
	}
	if ($myvar{'long_query_time'} &gt; 10) { push(@adjvars,&quot;long_query_time (&lt;= 10)&quot;); }
	if (defined($myvar{'log_slow_queries'})) {
		if ($myvar{'log_slow_queries'} eq &quot;OFF&quot;) { push(@generalrec,&quot;Enable the slow query log to troubleshoot bad queries&quot;); }
	}

	# Connections
	if ($mycalc{'pct_connections_used'} &gt; 85) {
		badprint &quot;Highest connection usage: $mycalc{'pct_connections_used'}%  ($mystat{'Max_used_connections'}/$myvar{'max_connections'})\n&quot;;
		push(@adjvars,&quot;max_connections (&gt; &quot;.$myvar{'max_connections'}.&quot;)&quot;);
		push(@adjvars,&quot;wait_timeout (&lt; &quot;.$myvar{'wait_timeout'}.&quot;)&quot;,&quot;interactive_timeout (&lt; &quot;.$myvar{'interactive_timeout'}.&quot;)&quot;);
		push(@generalrec,&quot;Reduce or eliminate persistent connections to reduce connection usage&quot;)
	} else {
		goodprint &quot;Highest usage of available connections: $mycalc{'pct_connections_used'}% ($mystat{'Max_used_connections'}/$myvar{'max_connections'})\n&quot;;
	}

	# Key buffer
	if (!defined($mycalc{'total_myisam_indexes'}) and $doremote == 1) {
		push(@generalrec,&quot;Unable to calculate MyISAM indexes on remote MySQL server &lt; 5.0.0&quot;);
	} elsif ($mycalc{'total_myisam_indexes'} =~ /^fail$/) {
		badprint &quot;Cannot calculate MyISAM index size - re-run script as root user\n&quot;;
	} elsif ($mycalc{'total_myisam_indexes'} == &quot;0&quot;) {
		badprint &quot;None of your MyISAM tables are indexed - add indexes immediately\n&quot;;
	} else {
		if ($myvar{'key_buffer_size'} &lt; $mycalc{'total_myisam_indexes'} &amp;&amp; $mycalc{'pct_keys_from_mem'} &lt; 95) {
			badprint &quot;Key buffer size / total MyISAM indexes: &quot;.hr_bytes($myvar{'key_buffer_size'}).&quot;/&quot;.hr_bytes($mycalc{'total_myisam_indexes'}).&quot;\n&quot;;
			push(@adjvars,&quot;key_buffer_size (&gt; &quot;.hr_bytes($mycalc{'total_myisam_indexes'}).&quot;)&quot;);
		} else {
			goodprint &quot;Key buffer size / total MyISAM indexes: &quot;.hr_bytes($myvar{'key_buffer_size'}).&quot;/&quot;.hr_bytes($mycalc{'total_myisam_indexes'}).&quot;\n&quot;;
		}
		if ($mystat{'Key_read_requests'} &gt; 0) {
			if ($mycalc{'pct_keys_from_mem'} &lt; 95) {
				badprint &quot;Key buffer hit rate: $mycalc{'pct_keys_from_mem'}% (&quot;.hr_num($mystat{'Key_read_requests'}).&quot; cached / &quot;.hr_num($mystat{'Key_reads'}).&quot; reads)\n&quot;;
			} else {
				goodprint &quot;Key buffer hit rate: $mycalc{'pct_keys_from_mem'}% (&quot;.hr_num($mystat{'Key_read_requests'}).&quot; cached / &quot;.hr_num($mystat{'Key_reads'}).&quot; reads)\n&quot;;
			}
		} else {
			# No queries have run that would use keys
		}
	}

	# Query cache
	if ($mysqlvermajor &lt; 4) {
		# MySQL versions &lt; 4.01 don't support query caching
		push(@generalrec,&quot;Upgrade MySQL to version 4+ to utilize query caching&quot;);
	} elsif ($myvar{'query_cache_size'} &lt; 1) {
		badprint &quot;Query cache is disabled\n&quot;;
		push(@adjvars,&quot;query_cache_size (&gt;= 8M)&quot;);
	} elsif ($mystat{'Com_select'} == 0) {
		badprint &quot;Query cache cannot be analyzed - no SELECT statements executed\n&quot;;
	} else {
		if ($mycalc{'query_cache_efficiency'} &lt; 20) {
			badprint &quot;Query cache efficiency: $mycalc{'query_cache_efficiency'}% (&quot;.hr_num($mystat{'Qcache_hits'}).&quot; cached / &quot;.hr_num($mystat{'Qcache_hits'}+$mystat{'Com_select'}).&quot; selects)\n&quot;;
			push(@adjvars,&quot;query_cache_limit (&gt; &quot;.hr_bytes_rnd($myvar{'query_cache_limit'}).&quot;, or use smaller result sets)&quot;);
		} else {
			goodprint &quot;Query cache efficiency: $mycalc{'query_cache_efficiency'}% (&quot;.hr_num($mystat{'Qcache_hits'}).&quot; cached / &quot;.hr_num($mystat{'Qcache_hits'}+$mystat{'Com_select'}).&quot; selects)\n&quot;;
		}
		if ($mycalc{'query_cache_prunes_per_day'} &gt; 98) {
			badprint &quot;Query cache prunes per day: $mycalc{'query_cache_prunes_per_day'}\n&quot;;
			if ($myvar{'query_cache_size'} &gt; 128*1024*1024) {
			    push(@generalrec,&quot;Increasing the query_cache size over 128M may reduce performance&quot;);
		        push(@adjvars,&quot;query_cache_size (&gt; &quot;.hr_bytes_rnd($myvar{'query_cache_size'}).&quot;) [see warning above]&quot;);
			} else {
		        push(@adjvars,&quot;query_cache_size (&gt; &quot;.hr_bytes_rnd($myvar{'query_cache_size'}).&quot;)&quot;);
			}
		} else {
			goodprint &quot;Query cache prunes per day: $mycalc{'query_cache_prunes_per_day'}\n&quot;;
		}
	}

	# Sorting
	if ($mycalc{'total_sorts'} == 0) {
		# For the sake of space, we will be quiet here
		# No sorts have run yet
	} elsif ($mycalc{'pct_temp_sort_table'} &gt; 10) {
		badprint &quot;Sorts requiring temporary tables: $mycalc{'pct_temp_sort_table'}% (&quot;.hr_num($mystat{'Sort_merge_passes'}).&quot; temp sorts / &quot;.hr_num($mycalc{'total_sorts'}).&quot; sorts)\n&quot;;
		push(@adjvars,&quot;sort_buffer_size (&gt; &quot;.hr_bytes_rnd($myvar{'sort_buffer_size'}).&quot;)&quot;);
		push(@adjvars,&quot;read_rnd_buffer_size (&gt; &quot;.hr_bytes_rnd($myvar{'read_rnd_buffer_size'}).&quot;)&quot;);
	} else {
		goodprint &quot;Sorts requiring temporary tables: $mycalc{'pct_temp_sort_table'}% (&quot;.hr_num($mystat{'Sort_merge_passes'}).&quot; temp sorts / &quot;.hr_num($mycalc{'total_sorts'}).&quot; sorts)\n&quot;;
	}

	# Joins
	if ($mycalc{'joins_without_indexes_per_day'} &gt; 250) {
		badprint &quot;Joins performed without indexes: $mycalc{'joins_without_indexes'}\n&quot;;
		push(@adjvars,&quot;join_buffer_size (&gt; &quot;.hr_bytes($myvar{'join_buffer_size'}).&quot;, or always use indexes with joins)&quot;);
		push(@generalrec,&quot;Adjust your join queries to always utilize indexes&quot;);
	} else {
		# For the sake of space, we will be quiet here
		# No joins have run without indexes
	}

	# Temporary tables
	if ($mystat{'Created_tmp_tables'} &gt; 0) {
		if ($mycalc{'pct_temp_disk'} &gt; 25 &amp;&amp; $mycalc{'max_tmp_table_size'} &lt; 256*1024*1024) {
			badprint &quot;Temporary tables created on disk: $mycalc{'pct_temp_disk'}% (&quot;.hr_num($mystat{'Created_tmp_disk_tables'}).&quot; on disk / &quot;.hr_num($mystat{'Created_tmp_disk_tables'} + $mystat{'Created_tmp_tables'}).&quot; total)\n&quot;;
			push(@adjvars,&quot;tmp_table_size (&gt; &quot;.hr_bytes_rnd($myvar{'tmp_table_size'}).&quot;)&quot;);
			push(@adjvars,&quot;max_heap_table_size (&gt; &quot;.hr_bytes_rnd($myvar{'max_heap_table_size'}).&quot;)&quot;);
			push(@generalrec,&quot;When making adjustments, make tmp_table_size/max_heap_table_size equal&quot;);
			push(@generalrec,&quot;Reduce your SELECT DISTINCT queries without LIMIT clauses&quot;);
		} elsif ($mycalc{'pct_temp_disk'} &gt; 25 &amp;&amp; $mycalc{'max_tmp_table_size'} &gt;= 256) {
			badprint &quot;Temporary tables created on disk: $mycalc{'pct_temp_disk'}% (&quot;.hr_num($mystat{'Created_tmp_disk_tables'}).&quot; on disk / &quot;.hr_num($mystat{'Created_tmp_disk_tables'} + $mystat{'Created_tmp_tables'}).&quot; total)\n&quot;;
			push(@generalrec,&quot;Temporary table size is already large - reduce result set size&quot;);
			push(@generalrec,&quot;Reduce your SELECT DISTINCT queries without LIMIT clauses&quot;);
		} else {
			goodprint &quot;Temporary tables created on disk: $mycalc{'pct_temp_disk'}% (&quot;.hr_num($mystat{'Created_tmp_disk_tables'}).&quot; on disk / &quot;.hr_num($mystat{'Created_tmp_disk_tables'} + $mystat{'Created_tmp_tables'}).&quot; total)\n&quot;;
		}
	} else {
		# For the sake of space, we will be quiet here
		# No temporary tables have been created
	}

	# Thread cache
	if ($myvar{'thread_cache_size'} eq 0) {
		badprint &quot;Thread cache is disabled\n&quot;;
		push(@generalrec,&quot;Set thread_cache_size to 4 as a starting value&quot;);
		push(@adjvars,&quot;thread_cache_size (start at 4)&quot;);
	} else {
		if ($mycalc{'thread_cache_hit_rate'} &lt;= 50) {
			badprint &quot;Thread cache hit rate: $mycalc{'thread_cache_hit_rate'}% (&quot;.hr_num($mystat{'Threads_created'}).&quot; created / &quot;.hr_num($mystat{'Connections'}).&quot; connections)\n&quot;;
			push(@adjvars,&quot;thread_cache_size (&gt; $myvar{'thread_cache_size'})&quot;);
		} else {
			goodprint &quot;Thread cache hit rate: $mycalc{'thread_cache_hit_rate'}% (&quot;.hr_num($mystat{'Threads_created'}).&quot; created / &quot;.hr_num($mystat{'Connections'}).&quot; connections)\n&quot;;
		}
	}

	# Table cache
	if ($mystat{'Open_tables'} &gt; 0) {
		if ($mycalc{'table_cache_hit_rate'} &lt; 20) {
			badprint &quot;Table cache hit rate: $mycalc{'table_cache_hit_rate'}% (&quot;.hr_num($mystat{'Open_tables'}).&quot; open / &quot;.hr_num($mystat{'Opened_tables'}).&quot; opened)\n&quot;;
			if ($mysqlvermajor eq 6 || ($mysqlvermajor eq 5 &amp;&amp; $mysqlverminor ge 1)) {
				push(@adjvars,&quot;table_cache (&gt; &quot;.$myvar{'table_open_cache'}.&quot;)&quot;);
			} else {
				push(@adjvars,&quot;table_cache (&gt; &quot;.$myvar{'table_cache'}.&quot;)&quot;);
			}
			push(@generalrec,&quot;Increase table_cache gradually to avoid file descriptor limits&quot;);
		} else {
			goodprint &quot;Table cache hit rate: $mycalc{'table_cache_hit_rate'}% (&quot;.hr_num($mystat{'Open_tables'}).&quot; open / &quot;.hr_num($mystat{'Opened_tables'}).&quot; opened)\n&quot;;
		}
	}

	# Open files
	if (defined $mycalc{'pct_files_open'}) {
		if ($mycalc{'pct_files_open'} &gt; 85) {
			badprint &quot;Open file limit used: $mycalc{'pct_files_open'}% (&quot;.hr_num($mystat{'Open_files'}).&quot;/&quot;.hr_num($myvar{'open_files_limit'}).&quot;)\n&quot;;
			push(@adjvars,&quot;open_files_limit (&gt; &quot;.$myvar{'open_files_limit'}.&quot;)&quot;);
		} else {
			goodprint &quot;Open file limit used: $mycalc{'pct_files_open'}% (&quot;.hr_num($mystat{'Open_files'}).&quot;/&quot;.hr_num($myvar{'open_files_limit'}).&quot;)\n&quot;;
		}
	}

	# Table locks
	if (defined $mycalc{'pct_table_locks_immediate'}) {
		if ($mycalc{'pct_table_locks_immediate'} &lt; 95) {
			badprint &quot;Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}%\n&quot;;
			push(@generalrec,&quot;Optimize queries and/or use InnoDB to reduce lock wait&quot;);
		} else {
			goodprint &quot;Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}% (&quot;.hr_num($mystat{'Table_locks_immediate'}).&quot; immediate / &quot;.hr_num($mystat{'Table_locks_waited'}+$mystat{'Table_locks_immediate'}).&quot; locks)\n&quot;;
		}
	}

	# Performance options
	if ($mysqlvermajor == 3 || ($mysqlvermajor == 4 &amp;&amp; $mysqlverminor == 0)) {
		push(@generalrec,&quot;Upgrade to MySQL 4.1+ to use concurrent MyISAM inserts&quot;);
	} elsif ($myvar{'concurrent_insert'} eq &quot;OFF&quot;) {
		push(@generalrec,&quot;Enable concurrent_insert by setting it to 'ON'&quot;);
	} elsif ($myvar{'concurrent_insert'} eq 0) {
		push(@generalrec,&quot;Enable concurrent_insert by setting it to 1&quot;);
	}
	if ($mycalc{'pct_aborted_connections'} &gt; 5) {
		badprint &quot;Connections aborted: &quot;.$mycalc{'pct_aborted_connections'}.&quot;%\n&quot;;
		push(@generalrec,&quot;Your applications are not closing MySQL connections properly&quot;);
	}

	# InnoDB
	if (defined $myvar{'have_innodb'} &amp;&amp; $myvar{'have_innodb'} eq &quot;YES&quot; &amp;&amp; defined $enginestats{'InnoDB'}) {
		if ($myvar{'innodb_buffer_pool_size'} &gt; $enginestats{'InnoDB'}) {
			goodprint &quot;InnoDB data size / buffer pool: &quot;.hr_bytes($enginestats{'InnoDB'}).&quot;/&quot;.hr_bytes($myvar{'innodb_buffer_pool_size'}).&quot;\n&quot;;
		} else {
			badprint &quot;InnoDB data size / buffer pool: &quot;.hr_bytes($enginestats{'InnoDB'}).&quot;/&quot;.hr_bytes($myvar{'innodb_buffer_pool_size'}).&quot;\n&quot;;
			push(@adjvars,&quot;innodb_buffer_pool_size (&gt;= &quot;.hr_bytes_rnd($enginestats{'InnoDB'}).&quot;)&quot;);
		}
	}
}

# Take the two recommendation arrays and display them at the end of the output
sub make_recommendations {
	print &quot;\n-------- Recommendations -----------------------------------------------------\n&quot;;
	if (@generalrec &gt; 0) {
		print &quot;General recommendations:\n&quot;;
		foreach (@generalrec) { print &quot;    &quot;.$_.&quot;\n&quot;; }
	}
	if (@adjvars &gt; 0) {
		print &quot;Variables to adjust:\n&quot;;
		if ($mycalc{'pct_physical_memory'} &gt; 90) {
			print &quot;  *** MySQL's maximum memory usage is dangerously high ***\n&quot;.
				  &quot;  *** Add RAM before increasing MySQL buffer variables ***\n&quot;;
		}
		foreach (@adjvars) { print &quot;    &quot;.$_.&quot;\n&quot;; }
	}
	if (@generalrec == 0 &amp;&amp; @adjvars ==0) {
		print &quot;No additional performance recommendations are available.\n&quot;
	}
	print &quot;\n&quot;;
}

# ---------------------------------------------------------------------------
# BEGIN 'MAIN'
# ---------------------------------------------------------------------------
print	&quot;\n &gt;&gt;  MySQLTuner $tunerversion - Major Hayden &lt;major\@mhtx.net&gt;\n&quot;.
		&quot; &gt;&gt;  Bug reports, feature requests, and downloads at http://mysqltuner.com/\n&quot;.
		&quot; &gt;&gt;  Run with '--help' for additional options and output filtering\n&quot;;
mysql_setup;					# Gotta login first
os_setup;						# Set up some OS variables
get_all_vars;					# Toss variables/status into hashes
validate_tuner_version;			# Check current MySQLTuner version
validate_mysql_version;			# Check current MySQL version
check_architecture;				# Suggest 64-bit upgrade
check_storage_engines;			# Show enabled storage engines
calculations;					# Calculate everything we need
mysql_stats;					# Print the server stats
make_recommendations;			# Make recommendations based on stats
# ---------------------------------------------------------------------------
# END 'MAIN'
# ---------------------------------------------------------------------------
</pre></p>
<p><a style="font-family:Helvetica,Arial,Sans-serif;font-style:normal;font-variant:normal;font-weight:normal;font-size:14px;line-height:normal;display:block;text-decoration:underline;margin:12px auto 6px;" title="View Mysql Query Tuning on Scribd" href="http://www.scribd.com/doc/16038174/Mysql-Query-Tuning-">Mysql Query Tuning </a> </p>
<p>1.-<a href="http://www.webexperto.com/articulos/art/267/optimizar-consultas-mysql/">http://www.webexperto.com/articulos/art/267/optimizar-consultas-mysql/</a></p>
<p>2.-</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redcloverbi.wordpress.com/467/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redcloverbi.wordpress.com/467/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redcloverbi.wordpress.com/467/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redcloverbi.wordpress.com&amp;blog=5503751&amp;post=467&amp;subd=redcloverbi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redcloverbi.wordpress.com/2010/07/31/mysql-optimizar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e3cd836785c5cc0e21aaf997872e647?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravamo</media:title>
		</media:content>
	</item>
	</channel>
</rss>
