<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CKAN: Ticket #917: Turning off Autoflush in SQLAlchemy</title>
    <link>http://localhost/ticket/917</link>
    <description>&lt;p&gt;
David Raznik: I propose we remove autoflush by default in ckan.  It caused a lot of bugs on the version upgrade due to its magical behavior.
&lt;/p&gt;
&lt;p&gt;
I have a patch in &lt;a class="ext-link" href="https://bitbucket.org/kindly/ckan/"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;https://bitbucket.org/kindly/ckan/&lt;/a&gt;    on branch   feature_switch_autoflush_off_by_default.
&lt;/p&gt;
&lt;p&gt;
This change simplifies code.  It only took 7 extra flushes/commits to make work and there are over 40 instances that we remove autoflush, so as not to cause error (I have not removed them in the patch yet).
&lt;/p&gt;
&lt;p&gt;
Things to know about using flush:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Most of the time nothing will change.   A commit implies flush.
&lt;/li&gt;&lt;li&gt;You only need to flush if you expect a query to return an object you just saved.    i.e  if you  session.add(obj)  and you expect obj to be in a session.query.
&lt;/li&gt;&lt;li&gt;A flush is handy when you want to get the primary key out before you do a commit.  i.e   session.add(obj);  session.flush();  obj.id  is now generated.
&lt;/li&gt;&lt;li&gt;You can use them as a limited form of nested transaction.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
It increased the performance on the tests by about 5%.  There are less flushes altogether so is faster.
&lt;/p&gt;
&lt;p&gt;
I do not see any downsides.
&lt;/p&gt;
</description>
    <language>en-us</language>
    <image>
      <title>CKAN</title>
      <url>http://assets.okfn.org/p/ckan/img/ckan_logo_shortname.png</url>
      <link>http://localhost/ticket/917</link>
    </image>
    <generator>Trac 0.12.3</generator>
    <item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 17 Jan 2011 16:03:00 GMT</pubDate>
      <title>reporter changed; owner set</title>
      <link>http://localhost/ticket/917#comment:1</link>
      <guid isPermaLink="false">http://localhost/ticket/917#comment:1</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;owner&lt;/strong&gt;
              set to &lt;em&gt;kindly&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;reporter&lt;/strong&gt;
              changed from &lt;em&gt;dread&lt;/em&gt; to &lt;em&gt;kindly&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 17 Jan 2011 16:03:15 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/917#comment:2</link>
      <guid isPermaLink="false">http://localhost/ticket/917#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;new&lt;/em&gt; to &lt;em&gt;closed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                set to &lt;em&gt;fixed&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 17 Jan 2011 16:03:52 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/917#comment:3</link>
      <guid isPermaLink="false">http://localhost/ticket/917#comment:3</guid>
      <description>
        &lt;p&gt;
Fixed in cset:f2865f43d8ee
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>