<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mysql on Yang's Blog</title><link>https://blog.yangtheman.com/tags/mysql/</link><description>Recent content in Mysql on Yang's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Yang Chung</copyright><lastBuildDate>Sat, 30 Jan 2010 07:55:21 +0000</lastBuildDate><atom:link href="https://blog.yangtheman.com/tags/mysql/index.xml" rel="self" type="application/rss+xml"/><item><title>How to convert from MySQL to Postgres</title><link>https://blog.yangtheman.com/2010/01/30/how-to-convert-from-mysql-to-postgres/</link><pubDate>Sat, 30 Jan 2010 07:55:21 +0000</pubDate><guid>https://blog.yangtheman.com/2010/01/30/how-to-convert-from-mysql-to-postgres/</guid><description>&lt;p&gt;I have been using MySQL for probably as long as I could remember. For &lt;a href="http://www.bloglation.com" target="_blank" rel="noreferrer"&gt;Bloglation&lt;/a&gt;, search capability is an important feature since it&amp;rsquo;s hard to browse each post one by one. I will probably implement tagging functionality, but even so, it&amp;rsquo;s important to be able to search the contents with a keyword(s). While Ultrasphinx works well, Heroku only supports WebSolr&amp;hellip; I was using acts_as_ferret using /tmp for index files, but the problem using the /tmp directory is that ferret index files most likely to disappear at some point.&lt;/p&gt;
&lt;p&gt;Then, I found out that Postgres supports full-text search and since Heroku uses Postgres, I could use other plug-ins like &lt;a href="http://code.google.com/p/acts-as-tsearch/" target="_blank" rel="noreferrer"&gt;acts_as_tsearch&lt;/a&gt; or &lt;a href="http://tenderlovemaking.com/2009/10/17/full-text-search-on-heroku/comment-page-1/" target="_blank" rel="noreferrer"&gt;texticle&lt;/a&gt; for free. Free is important to me, since it&amp;rsquo;s not making any money.&lt;/p&gt;
&lt;p&gt;Searching online, there are various ways to do it like &lt;a href="http://pivotallabs.com/users/jpignata/blog/articles/1077-converting-rails-application-data-from-mysql-to-postgresql" target="_blank" rel="noreferrer"&gt;Pivotal Labs&amp;rsquo; script&lt;/a&gt; or &lt;a href="http://adam.blog.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/" target="_blank" rel="noreferrer"&gt;Heroku&amp;rsquo;s Taps gem&lt;/a&gt;, but I wanted to do it in an old way like &lt;a href="http://blog.aedifice.org/2009/09/08/converting-rails-applications-from-mysql-to-postgresql" target="_blank" rel="noreferrer"&gt;AEdifice&lt;/a&gt; to check everything is going alright at each step. &lt;strong&gt;1. First thing to do is to backup MySQL&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For me, it was important to backup preserving encoding, since it had many different languages. First I pulled db from Heroku thinking that I&lt;/p&gt;</description></item><item><title>Counting rows and modifying MySQL to work with Postgres or Heroku</title><link>https://blog.yangtheman.com/2009/10/22/counting-rows-and-modifying-mysql-to-work-with-postgres-or-heroku/</link><pubDate>Thu, 22 Oct 2009 07:48:03 +0000</pubDate><guid>https://blog.yangtheman.com/2009/10/22/counting-rows-and-modifying-mysql-to-work-with-postgres-or-heroku/</guid><description>&lt;p&gt;Now I am moving on to Open Translation Project. I&amp;rsquo;ve done some translation work before, including one of Paul Graham&amp;rsquo;s essay - &lt;a href="http://www.paulgraham.com/notnot.html" target="_blank" rel="noreferrer"&gt;Why to not not start a startup&lt;/a&gt;. BTW, he finally made a link from the essay to my translation. I used Google Translate as base, but I couldn&amp;rsquo;t believe how bad the translation was. Yahoo&amp;rsquo;s Babel Fish was a little better, but not as much. That&amp;rsquo;s where I got the idea of creating this possibly massive project.&lt;/p&gt;
&lt;p&gt;Anyhow, I wanted to find a way of selecting an article or blog that was translated the most. I had one model that stored basic information of original article/blog. Then its children are translations. So, I need to count rows of children with the same parent. In MySQL, I had the following statement in Rails.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;@top_origs = OrigPost.find(:all,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :select =&amp;gt; &amp;#39;orig_posts.*, count(posts.id) as post_count&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :joins =&amp;gt; &amp;#39;left outer join posts on posts.orig_post_id = orig_posts.id&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :group =&amp;gt; &amp;#39;orig_posts.id&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :order =&amp;gt; &amp;#39;post_count DESC&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :limit =&amp;gt; 5)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item></channel></rss>