<?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/"
	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>Comments on: Announcing postgresql-simple</title>
	<atom:link href="http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/</link>
	<description>Math, Computer Science,  and Education</description>
	<lastBuildDate>Wed, 08 May 2013 14:59:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: lpsmith</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-162</link>
		<dc:creator><![CDATA[lpsmith]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 22:45:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-162</guid>
		<description><![CDATA[Ahh, so I wasn&#039;t correctly recalling the internals of HDBC-postgresql (or even the details of libpq, for that matter.)   HDBC does not do escaping itself,  but rather uses &lt;code&gt;execParams&lt;/code&gt;.  The reason postgresql-simple doesn&#039;t use protocol level parameters is because mysql-simple didn&#039;t,  and this was the most straightforward port of mysql-simple to PostgreSQL I could manage.

However,  my understanding of the client protocol is that only prepared statements support protocol-level parameters;   what is unclear to me at the moment is whether  &lt;code&gt;execParams&lt;/code&gt; is just a convenient composition of &lt;code&gt;prepare&lt;/code&gt; and &lt;code&gt;execPrepared&lt;/code&gt; that involves two round trips to the server to excute a query,  or if &lt;code&gt;execParams&lt;/code&gt; uses a certain trick so that there is only one round trip involved.   I figure there is a decent probability of either possibility,  though I would definitely favor the latter.   I suppose I&#039;ll have to fire up WireShark and/or read the source.

There is one definite disadvantage of &lt;code&gt;execParams&lt;/code&gt;, and that is it doesn&#039;t allow multiple SQL statements to be bundled in one request, which is a pretty silly and arbitrary restriction in my opinion.    This means that more round-trips are needed in some cases,  and that parameter values will have to be sent multiple times in others.

There is a protocol-level trick that you can issue addition requests before the backend finishes responding to the current request,  and this trick could be used to reduce the number of round trips.   However,  libpq does not support this trick,  and must finish receiving the response for a given request before it can issue the next one,  though perhaps &lt;code&gt;execParams&lt;/code&gt; is a special-case of this trick.

And this is the advantage of a native Haskell solution that I was referring to;   a native Haskell library can use this trick and,  with the careful use of non-strict evaluation,  not muck up the interface exposed to the programmer.  From the programmers perspective it would still be a bunch of sequential, fully synchronous requests,  but the library would be able to issue a few more queries before it has gotten the complete response to the current query.  (As long as it has all the results needed to issue the next query, of course.)]]></description>
		<content:encoded><![CDATA[<p>Ahh, so I wasn&#8217;t correctly recalling the internals of HDBC-postgresql (or even the details of libpq, for that matter.)   HDBC does not do escaping itself,  but rather uses <code>execParams</code>.  The reason postgresql-simple doesn&#8217;t use protocol level parameters is because mysql-simple didn&#8217;t,  and this was the most straightforward port of mysql-simple to PostgreSQL I could manage.</p>
<p>However,  my understanding of the client protocol is that only prepared statements support protocol-level parameters;   what is unclear to me at the moment is whether  <code>execParams</code> is just a convenient composition of <code>prepare</code> and <code>execPrepared</code> that involves two round trips to the server to excute a query,  or if <code>execParams</code> uses a certain trick so that there is only one round trip involved.   I figure there is a decent probability of either possibility,  though I would definitely favor the latter.   I suppose I&#8217;ll have to fire up WireShark and/or read the source.</p>
<p>There is one definite disadvantage of <code>execParams</code>, and that is it doesn&#8217;t allow multiple SQL statements to be bundled in one request, which is a pretty silly and arbitrary restriction in my opinion.    This means that more round-trips are needed in some cases,  and that parameter values will have to be sent multiple times in others.</p>
<p>There is a protocol-level trick that you can issue addition requests before the backend finishes responding to the current request,  and this trick could be used to reduce the number of round trips.   However,  libpq does not support this trick,  and must finish receiving the response for a given request before it can issue the next one,  though perhaps <code>execParams</code> is a special-case of this trick.</p>
<p>And this is the advantage of a native Haskell solution that I was referring to;   a native Haskell library can use this trick and,  with the careful use of non-strict evaluation,  not muck up the interface exposed to the programmer.  From the programmers perspective it would still be a bunch of sequential, fully synchronous requests,  but the library would be able to issue a few more queries before it has gotten the complete response to the current query.  (As long as it has all the results needed to issue the next query, of course.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Weaver</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-160</link>
		<dc:creator><![CDATA[Philip Weaver]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 19:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-160</guid>
		<description><![CDATA[Great, I&#039;ll play around with the library some more and look into writing that patch.]]></description>
		<content:encoded><![CDATA[<p>Great, I&#8217;ll play around with the library some more and look into writing that patch.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lpsmith</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-159</link>
		<dc:creator><![CDATA[lpsmith]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 19:38:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-159</guid>
		<description><![CDATA[Yeah, that parsing step is what HDBC&#039;s preparation step caches.   IIRC, I think I removed that step and used the $n parameters in some of my apps.  I haven&#039;t personally benchmarked postgresql-simple&#039;s parser,  which was written by Bryan O&#039;Sullivan and imported from mysql-simple with no changes.

Sure, I&#039;d add support for that,  though I don&#039;t know when I&#039;d get to it.   Offering a patch would likely speed the process...]]></description>
		<content:encoded><![CDATA[<p>Yeah, that parsing step is what HDBC&#8217;s preparation step caches.   IIRC, I think I removed that step and used the $n parameters in some of my apps.  I haven&#8217;t personally benchmarked postgresql-simple&#8217;s parser,  which was written by Bryan O&#8217;Sullivan and imported from mysql-simple with no changes.</p>
<p>Sure, I&#8217;d add support for that,  though I don&#8217;t know when I&#8217;d get to it.   Offering a patch would likely speed the process&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Weaver</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-158</link>
		<dc:creator><![CDATA[Philip Weaver]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 19:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-158</guid>
		<description><![CDATA[It looks like the library doesn&#039;t use postgres query parameters underneath; it does the substitution itself, is that right?. Did you choose to do that so that you could identify errors in Haskell before querying the database?

In HDBC, there&#039;s a parsec parser that replaces &#039;?&#039; with $1, $2, and so on, and uses query parameters in the postgres query. We found that the parser was horribly inefficient, and that it was using a majority of the CPU time and memory allocation in our program. Hopefully yours is a lot faster, since it is written in attoparsec. Have you profiled your parser?

We have no need for the library to replace &#039;?&#039; with $1 for us. We want to be able to write our queries using $-style parameters, but it looks like postgresql-simple does not support that. Would you consider adding it?]]></description>
		<content:encoded><![CDATA[<p>It looks like the library doesn&#8217;t use postgres query parameters underneath; it does the substitution itself, is that right?. Did you choose to do that so that you could identify errors in Haskell before querying the database?</p>
<p>In HDBC, there&#8217;s a parsec parser that replaces &#8216;?&#8217; with $1, $2, and so on, and uses query parameters in the postgres query. We found that the parser was horribly inefficient, and that it was using a majority of the CPU time and memory allocation in our program. Hopefully yours is a lot faster, since it is written in attoparsec. Have you profiled your parser?</p>
<p>We have no need for the library to replace &#8216;?&#8217; with $1 for us. We want to be able to write our queries using $-style parameters, but it looks like postgresql-simple does not support that. Would you consider adding it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lpsmith</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-157</link>
		<dc:creator><![CDATA[lpsmith]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 12:27:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-157</guid>
		<description><![CDATA[Well,  postgresql-simple has some rough edges, though hopefully a few less rough edges than pgsql-simple.    I did give it version 0.0 for a reason,  and interfaces may change.

I did do a quick-and-dirty editing of mysql-simple&#039;s haddock comments.   You should be able to read them yourself if you build the package,  or wait for hackage to build the docs for you.]]></description>
		<content:encoded><![CDATA[<p>Well,  postgresql-simple has some rough edges, though hopefully a few less rough edges than pgsql-simple.    I did give it version 0.0 for a reason,  and interfaces may change.</p>
<p>I did do a quick-and-dirty editing of mysql-simple&#8217;s haddock comments.   You should be able to read them yourself if you build the package,  or wait for hackage to build the docs for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tcrayford</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-156</link>
		<dc:creator><![CDATA[tcrayford]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 12:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-156</guid>
		<description><![CDATA[Awesome. I was just looking for something like this (need to use postgres via ssl, which pgsql-simple does not support).

Could you include a small README/docs? You could probably base them off the mysql-simple docs pretty easily.]]></description>
		<content:encoded><![CDATA[<p>Awesome. I was just looking for something like this (need to use postgres via ssl, which pgsql-simple does not support).</p>
<p>Could you include a small README/docs? You could probably base them off the mysql-simple docs pretty easily.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lpsmith</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-155</link>
		<dc:creator><![CDATA[lpsmith]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 11:44:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-155</guid>
		<description><![CDATA[Yes, HDBC attempts to be a DBI-like interface,  with different backends.    And while I see value in that approach,  I also think that there is frequently good reason to commit to a particular database and use all the implementation-specific features and advantages conferred.   Unfortunately standard SQL seems a little too restrictive for many purposes,   and even then implementations violate the standard altogether too often.

Hopefully mysql-simple and postgresql-simple will be sufficiently close to each other that moving backends won&#039;t be too difficult,  if you&#039;ve paid attention to what database types you use, and steer clear of a lot of useful features,  etc.]]></description>
		<content:encoded><![CDATA[<p>Yes, HDBC attempts to be a DBI-like interface,  with different backends.    And while I see value in that approach,  I also think that there is frequently good reason to commit to a particular database and use all the implementation-specific features and advantages conferred.   Unfortunately standard SQL seems a little too restrictive for many purposes,   and even then implementations violate the standard altogether too often.</p>
<p>Hopefully mysql-simple and postgresql-simple will be sufficiently close to each other that moving backends won&#8217;t be too difficult,  if you&#8217;ve paid attention to what database types you use, and steer clear of a lot of useful features,  etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://blog.melding-monads.com/2011/12/30/announcing-postgresql-simple/#comment-154</link>
		<dc:creator><![CDATA[Adam]]></dc:creator>
		<pubDate>Fri, 30 Dec 2011 11:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.melding-monads.com/?p=382#comment-154</guid>
		<description><![CDATA[As a total beginner ramping up to create a tiny website based on Snap and PostgreSQL, your post and library comes at a perfect time - thanks!

In the Perl world there is an common database interface module, DBI, that is used to connect to all kinds of databases, using drivers specifically for each, i.e. DBD::Pg, DBD::mysql, DBD::DB2, DBD::Oracle, DBD::SQLite etc. Does a similar Haskell-project exist? It seems that a lot of generic stuff gets duplicated if you need a full database interface module per database (and switching backends become more of a hassle).

Just curious :-)]]></description>
		<content:encoded><![CDATA[<p>As a total beginner ramping up to create a tiny website based on Snap and PostgreSQL, your post and library comes at a perfect time &#8211; thanks!</p>
<p>In the Perl world there is an common database interface module, DBI, that is used to connect to all kinds of databases, using drivers specifically for each, i.e. DBD::Pg, DBD::mysql, DBD::DB2, DBD::Oracle, DBD::SQLite etc. Does a similar Haskell-project exist? It seems that a lot of generic stuff gets duplicated if you need a full database interface module per database (and switching backends become more of a hassle).</p>
<p>Just curious :-)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
