<?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/"
	>

<channel>
	<title>biotext.org.uk &#187; postgresql</title>
	<atom:link href="http://biotext.org.uk/tag/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://biotext.org.uk</link>
	<description>Not a typewriter</description>
	<lastBuildDate>Sat, 05 Feb 2011 14:18:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Execute SQL outside of a transaction in Hibernate</title>
		<link>http://biotext.org.uk/execute-sql-outside-of-a-transaction-in-hibernate/</link>
		<comments>http://biotext.org.uk/execute-sql-outside-of-a-transaction-in-hibernate/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 19:01:27 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=262</guid>
		<description><![CDATA[I hit upon a snag today &#8212; while PostgreSQL requires that certain maintenance commands (e.g. vacuum analyze) are executed outside of a transactional context, it&#8217;s actually quite hard to get at Hibernate&#8217;s underlying database connection directly. Each Session object has a connection() method which returns a JDBC connection object, but this actually turns out to [...]]]></description>
			<content:encoded><![CDATA[<p>I hit upon a snag today &#8212; while PostgreSQL requires that certain maintenance commands (e.g. <code>vacuum analyze</code>) are executed outside of a transactional context, it&#8217;s actually quite hard to get at Hibernate&#8217;s underlying database connection directly. Each <code>Session</code> object has a <code>connection()</code> method which returns a JDBC connection object, but this actually turns out to be a Hibernate-generated proxy for the real connection object, which refuses to work outside of a transaction.</p>
<p>You can probably get around this by using <a href="http://www.hibernate.org/403.html">autocommit mode</a> instead of explicit transactions, but this is a configuration property that affects your whole application, and is considered harmful.</p>
<p>Eventually I hit on a really dodgy workaround. You can manually rollback the transaction at the start of your SQL statement the old-fashioned way:</p>
<pre class="brush: xml">

&lt;sql-query name=&quot;nasty.hack&quot;&gt;
&lt;![CDATA[
rollback transaction; vacuum analyze;
]]&gt;
&lt;/sql-query&gt;
</pre>
<p>This also works when used with the <code>prepareStatement()</code> method as shown <a href="http://www.hibernate.org/118.html#A26">here</a>.</p>
<p>Frightening but effective. If you know of a better way, let me know!</p>
<p>Andrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/execute-sql-outside-of-a-transaction-in-hibernate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Finding out last VACUUM/ANALYZE times in PostgreSQL</title>
		<link>http://biotext.org.uk/finding-out-last-vacuumanalyze-times-in-postgresql/</link>
		<comments>http://biotext.org.uk/finding-out-last-vacuumanalyze-times-in-postgresql/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 18:47:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=257</guid>
		<description><![CDATA[When was my database last vacuumed or analyzed? This took me a while to figure out from googling around so I&#8217;ll put it here for posterity, short and sweet. select relname, last_vacuum, last_analyze from pg_stat_all_tables where schemaname = &#039;public&#039; Add the columns last_autovacuum or last_autoanalyze if you use those features. Andrew.]]></description>
			<content:encoded><![CDATA[<p>When was my database last vacuumed or analyzed? This took me a while to figure out from googling around so I&#8217;ll put it here for posterity, short and sweet.</p>
<pre class="brush: sql">
select relname, last_vacuum, last_analyze
from pg_stat_all_tables
where schemaname = &#039;public&#039;
</pre>
<p>Add the columns <code>last_autovacuum</code> or <code>last_autoanalyze</code> if you use those features.</p>
<p>Andrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/finding-out-last-vacuumanalyze-times-in-postgresql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

