<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MySQL to Postgres</title>
	<atom:link href="http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html</link>
	<description>Redfin Developers\' Blog</description>
	<lastBuildDate>Mon, 16 Nov 2009 21:49:52 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: shahaf.abileah</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5919</link>
		<dc:creator>shahaf.abileah</dc:creator>
		<pubDate>Tue, 02 Sep 2008 17:48:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5919</guid>
		<description>Yes, we essentially use DAO&#039;s just like we did before.

If you have a @ReadOnly annotated DAO and you try to use it to do an update, the update will be sent to the slave and it will fail with a SQLException.  The error is generated by a trigger that Slony creates on tables in the slave DB to prevent you from accidentally making changes to them.</description>
		<content:encoded><![CDATA[<p>Yes, we essentially use DAO&#8217;s just like we did before.</p>
<p>If you have a @ReadOnly annotated DAO and you try to use it to do an update, the update will be sent to the slave and it will fail with a SQLException.  The error is generated by a trigger that Slony creates on tables in the slave DB to prevent you from accidentally making changes to them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter Minden</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5720</link>
		<dc:creator>Walter Minden</dc:creator>
		<pubDate>Mon, 25 Aug 2008 10:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5720</guid>
		<description>First of all thanks for your quick reply!

So, you then just put your annotated DAOs in your service classes and use them as you did before, right?

So, you can&#039;t actually ever write data read from the slave back to the master because the DAO prohibits it? What happens when a service which is injected with a DAO that has a read only session factory tries to modify data, e.g. update()?</description>
		<content:encoded><![CDATA[<p>First of all thanks for your quick reply!</p>
<p>So, you then just put your annotated DAOs in your service classes and use them as you did before, right?</p>
<p>So, you can&#8217;t actually ever write data read from the slave back to the master because the DAO prohibits it? What happens when a service which is injected with a DAO that has a read only session factory tries to modify data, e.g. update()?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shahaf.abileah</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5678</link>
		<dc:creator>shahaf.abileah</dc:creator>
		<pubDate>Fri, 22 Aug 2008 14:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5678</guid>
		<description>We use Slony replication for both reasons: backup purposes and load balancing for better performance.

Our hibernate setup includes two separate connection definitions: one to the master DB and one to a slave DB.  All write operations go to the master (obviously).  *Most* read operations go to the slave (in some cases we read from the master DB, e.g. for queries where we can&#039;t tolerate any replication latency).

We use Guice dependency injection to initialize our DAO&#039;s with a SessionFactory, and we defined our own attributes to indicate whether a DAO should be initialized with a master DB SessionFactory (@ReadWrite) or a slave DB SessionFactory (@ReadOnly).

We&#039;ve been talking about setting up a 3rd attribute (@Reporting) that goes to a different slave, one that isn&#039;t guaranteed to be as up-to-date as the others but that is appropriate for &quot;heavy&quot; queries (for reporting purposes and such).</description>
		<content:encoded><![CDATA[<p>We use Slony replication for both reasons: backup purposes and load balancing for better performance.</p>
<p>Our hibernate setup includes two separate connection definitions: one to the master DB and one to a slave DB.  All write operations go to the master (obviously).  *Most* read operations go to the slave (in some cases we read from the master DB, e.g. for queries where we can&#8217;t tolerate any replication latency).</p>
<p>We use Guice dependency injection to initialize our DAO&#8217;s with a SessionFactory, and we defined our own attributes to indicate whether a DAO should be initialized with a master DB SessionFactory (@ReadWrite) or a slave DB SessionFactory (@ReadOnly).</p>
<p>We&#8217;ve been talking about setting up a 3rd attribute (@Reporting) that goes to a different slave, one that isn&#8217;t guaranteed to be as up-to-date as the others but that is appropriate for &#8220;heavy&#8221; queries (for reporting purposes and such).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter Minden</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5677</link>
		<dc:creator>Walter Minden</dc:creator>
		<pubDate>Fri, 22 Aug 2008 14:33:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5677</guid>
		<description>Im curious about how you take advantage of the slony replication via Hibernate or do you just use it for backup issues or similar?

I wonder how one would assert that data, read from the slave, gets never written back to the master? Two session factories and more db logic in business layers?</description>
		<content:encoded><![CDATA[<p>Im curious about how you take advantage of the slony replication via Hibernate or do you just use it for backup issues or similar?</p>
<p>I wonder how one would assert that data, read from the slave, gets never written back to the master? Two session factories and more db logic in business layers?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shahaf.abileah</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5054</link>
		<dc:creator>shahaf.abileah</dc:creator>
		<pubDate>Mon, 07 Jul 2008 15:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5054</guid>
		<description>Thanks for the suggestion Anton!

I just installed EMS SQL Manager Lite for Postgres and I agree that it&#039;s pretty good.  The only thing it lacks is the ability to edit fields in place (in the grid view), but otherwise it looks better than the others I&#039;ve tried.  I&#039;ll probably start using this one instead of my previous choice: DbVisualizer.</description>
		<content:encoded><![CDATA[<p>Thanks for the suggestion Anton!</p>
<p>I just installed EMS SQL Manager Lite for Postgres and I agree that it&#8217;s pretty good.  The only thing it lacks is the ability to edit fields in place (in the grid view), but otherwise it looks better than the others I&#8217;ve tried.  I&#8217;ll probably start using this one instead of my previous choice: DbVisualizer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton Fedorov</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-5039</link>
		<dc:creator>Anton Fedorov</dc:creator>
		<pubDate>Sun, 06 Jul 2008 16:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-5039</guid>
		<description>I can suggest you try EMS PgSql Managers.
It cool for GUI access to postgres.
I&#039;m use free version, but have tried trial pro version too -- its completely do what i want :)</description>
		<content:encoded><![CDATA[<p>I can suggest you try EMS PgSql Managers.<br />
It cool for GUI access to postgres.<br />
I&#8217;m use free version, but have tried trial pro version too &#8212; its completely do what i want <img src='http://blog.redfin.com/devblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shahaf.abileah</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-3958</link>
		<dc:creator>shahaf.abileah</dc:creator>
		<pubDate>Wed, 19 Mar 2008 02:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-3958</guid>
		<description>Matt, to answer your question...

So far we&#039;ve had pretty good luck with text search using TSearch2.  We haven&#039;t seen any records in our slow query log that involve TSearch2 queries, which means that they are all definitely under 200 ms.  In our testing they were well under that (more like 10 ms).  However, I should point out that our text search use cases are not particularly demanding.  We use TSearch2 to look for regions (e.g. cities, neighborhoods, zip codes, etc.) whose name matches what you type into the search box.  So, the number of queries is not huge and the volume of data to search is also not that big.  For example, we get far more queries after the region has been identified (by name) when it&#039;s time to look for listings that fit in that region&#039;s polygon, and the data to search through (all listings/properties) is also much bigger.

I haven&#039;t used Lecene myself, but a few of the other engineers here previously worked at Plum Tree, where I hear they did use Lucene.  What I gather is that it gives you more functionality than TSearch2, but it comes at the cost of having to maintain your DB and Lucene in sync.  Apparently there are some libraries that do some of this grunt work for you (e.g. in the hibernate OR layer), but I personally didn&#039;t investigate those too far.

At some point we will look to support a wider range of text search features on our side, and when we do I&#039;m sure we&#039;ll spend time thinking about whether to stick with TSearch2 or to go with something else.  For now it definitely does the job.</description>
		<content:encoded><![CDATA[<p>Matt, to answer your question&#8230;</p>
<p>So far we&#8217;ve had pretty good luck with text search using TSearch2.  We haven&#8217;t seen any records in our slow query log that involve TSearch2 queries, which means that they are all definitely under 200 ms.  In our testing they were well under that (more like 10 ms).  However, I should point out that our text search use cases are not particularly demanding.  We use TSearch2 to look for regions (e.g. cities, neighborhoods, zip codes, etc.) whose name matches what you type into the search box.  So, the number of queries is not huge and the volume of data to search is also not that big.  For example, we get far more queries after the region has been identified (by name) when it&#8217;s time to look for listings that fit in that region&#8217;s polygon, and the data to search through (all listings/properties) is also much bigger.</p>
<p>I haven&#8217;t used Lecene myself, but a few of the other engineers here previously worked at Plum Tree, where I hear they did use Lucene.  What I gather is that it gives you more functionality than TSearch2, but it comes at the cost of having to maintain your DB and Lucene in sync.  Apparently there are some libraries that do some of this grunt work for you (e.g. in the hibernate OR layer), but I personally didn&#8217;t investigate those too far.</p>
<p>At some point we will look to support a wider range of text search features on our side, and when we do I&#8217;m sure we&#8217;ll spend time thinking about whether to stick with TSearch2 or to go with something else.  For now it definitely does the job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shahaf.abileah</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-3957</link>
		<dc:creator>shahaf.abileah</dc:creator>
		<pubDate>Wed, 19 Mar 2008 02:17:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-3957</guid>
		<description>Thanks guys.

Kusum, to answer your question, the first step as you said would be to pull the polygon from the database, something like this:

select my_geometry_column from my_table where ST_Intersects(my_geometry_column, ST_GeomFromText(&#039;POINT(-122.299 47.609)&#039;,4326));

Now, this will give you the raw geometry representation, which is OK if you&#039;re using the PostGIS libraries -- you can use them to parse that binary blob and convert it into another representation that is suitable for the front-end.  Alternatively, you can use the astext() function to have the DB convert the geometry data into text form.

Either way, you&#039;ll then need to transfer that data to the client-side in order to display the polygon on the map.  We use Microsoft&#039;s Virtual Earth map API, which includes support for drawing polygons.    You can learn more about that API here: http://dev.live.com/virtualearth/sdk/

Incidentally, the query you&#039;re describing (find a polygon given a point) is different than our situation, currently.  Our queries are more like &quot;given a polygon, find all points in it&quot;.  But PostGIS supports both scenarios.</description>
		<content:encoded><![CDATA[<p>Thanks guys.</p>
<p>Kusum, to answer your question, the first step as you said would be to pull the polygon from the database, something like this:</p>
<p>select my_geometry_column from my_table where ST_Intersects(my_geometry_column, ST_GeomFromText(&#8217;POINT(-122.299 47.609)&#8217;,4326));</p>
<p>Now, this will give you the raw geometry representation, which is OK if you&#8217;re using the PostGIS libraries &#8212; you can use them to parse that binary blob and convert it into another representation that is suitable for the front-end.  Alternatively, you can use the astext() function to have the DB convert the geometry data into text form.</p>
<p>Either way, you&#8217;ll then need to transfer that data to the client-side in order to display the polygon on the map.  We use Microsoft&#8217;s Virtual Earth map API, which includes support for drawing polygons.    You can learn more about that API here: <a href="http://dev.live.com/virtualearth/sdk/" rel="nofollow">http://dev.live.com/virtualearth/sdk/</a></p>
<p>Incidentally, the query you&#8217;re describing (find a polygon given a point) is different than our situation, currently.  Our queries are more like &#8220;given a polygon, find all points in it&#8221;.  But PostGIS supports both scenarios.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-3956</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 19 Mar 2008 01:27:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-3956</guid>
		<description>Hi Shahaf, thanks a lot for that super-informative post.

Are you able to share any experiences &amp; stats about PostgreSQL&#039;s full-text search performance?  I have used PostgreSQL in a few production environments &amp; can vouch for its predictability &amp; stability, especially when coupled with OCaml.  But I&#039;ve not used the FTS feature, would prefer to use PostgreSQL&#039;s FTS than an external solution eg Lucene.

Thanks again!
Matt</description>
		<content:encoded><![CDATA[<p>Hi Shahaf, thanks a lot for that super-informative post.</p>
<p>Are you able to share any experiences &amp; stats about PostgreSQL&#8217;s full-text search performance?  I have used PostgreSQL in a few production environments &amp; can vouch for its predictability &amp; stability, especially when coupled with OCaml.  But I&#8217;ve not used the FTS feature, would prefer to use PostgreSQL&#8217;s FTS than an external solution eg Lucene.</p>
<p>Thanks again!<br />
Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kusum</title>
		<link>http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html/comment-page-1#comment-3850</link>
		<dc:creator>kusum</dc:creator>
		<pubDate>Sat, 15 Mar 2008 05:02:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.redfin.com/devblog/2008/02/mysql_to_postgres.html#comment-3850</guid>
		<description>Hii Shahaf
A great post.
I am new to postgresql.We have made our polygon database in postgresql and are trying to perform polygon search using it.
We are trying to find a particular point lies in which polygon and after finding that polygon we have to highlight it on map.
The thing is if we are able to find the desired polygon in datbase we are not able to get how we will be able to find its vertices to highlight it on map.
basicaly a polygon search.
Please help if u have any information regarding this or if you can give me an example that would be great.

Thanks in advance
Kusum</description>
		<content:encoded><![CDATA[<p>Hii Shahaf<br />
A great post.<br />
I am new to postgresql.We have made our polygon database in postgresql and are trying to perform polygon search using it.<br />
We are trying to find a particular point lies in which polygon and after finding that polygon we have to highlight it on map.<br />
The thing is if we are able to find the desired polygon in datbase we are not able to get how we will be able to find its vertices to highlight it on map.<br />
basicaly a polygon search.<br />
Please help if u have any information regarding this or if you can give me an example that would be great.</p>
<p>Thanks in advance<br />
Kusum</p>
]]></content:encoded>
	</item>
</channel>
</rss>
