<?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>Manitou-Mail Blog</title>
	<atom:link href="http://www.manitou-mail.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.manitou-mail.org/blog</link>
	<description>on the use and development of the Manitou-Mail program</description>
	<lastBuildDate>Wed, 29 Feb 2012 19:56:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL functions for tags</title>
		<link>http://www.manitou-mail.org/blog/2012/02/sql-functions-for-tags/</link>
		<comments>http://www.manitou-mail.org/blog/2012/02/sql-functions-for-tags/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 19:56:08 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=241</guid>
		<description><![CDATA[<p>Tags in Manitou-mail are hierarchical, for several reasons such as the ability to mimic folders. There are pros and cons of this choice, but from the point of view of SQL querying, tree-like structures are clearly more complicated than flat structures. Here are two functions in the wiki that could be of help to compare [...]]]></description>
			<content:encoded><![CDATA[<p>Tags in Manitou-mail are hierarchical, for several reasons such as the ability to mimic folders. There are pros and cons of this choice, but from the point of view of SQL querying, tree-like structures are clearly more complicated than flat structures. Here are <a href="http://www.manitou-mail.org/wiki/doku.php/support_functions" title="tag_path() and tag_depth()">two functions</a> in the wiki that could be of help to compare tags across hierarchies: </p>
<ul>
<li><b>tag_path(tag_id)</b> returns the full hierarchical path of a tag, with -&gt; as the separator between branches.
<li><b>tag_depth(tag_id)</b> returns the depth of the tag inside its hierarchy, starting at 1
</ul>
<p>As an example of use, in the custom queries of the user interface, we could use this query:<br />
<code><br />
select mail_id from mail_tags mt join tags t on (mt.tag=t.tag_id) where tag_path(t.tag_id) ilike 'ParentTag-&gt;%'<br />
</code><br />
to retrieve any message tagged with any tag whose top-level ancestor is &#8216;ParentTag&#8217;, no matter how deep the tag is inside the hierarchy (child, grandchild, grand grandchild&#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2012/02/sql-functions-for-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Attachment uploader reloaded</title>
		<link>http://www.manitou-mail.org/blog/2012/02/attachment-uploader-reloaded/</link>
		<comments>http://www.manitou-mail.org/blog/2012/02/attachment-uploader-reloaded/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 18:43:06 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[New features]]></category>
		<category><![CDATA[Usage]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=232</guid>
		<description><![CDATA[<p>The attachment uploader is a plugin that solves the problem of attachments that are too big to be transferred by mail. It requires no specific action from the person who composes the mail: on the client side, the user attaches the files as usual. This is important because the users are often not aware that [...]]]></description>
			<content:encoded><![CDATA[<p>The attachment uploader is a plugin that solves the problem of attachments that are too big to be transferred by mail. It requires no specific action from the person who composes the mail: on the client side, the user attaches the files as usual. This is important because the users are often not aware that sending huge files by e-mail is troublesome.</p>
<p>The upload happens on the server side: before passing outgoing messages to the delivery service, the plugin checks for attachments bigger than the configured size, and when found, transfers them to a web server, under a random-generated directory name. Inside the message, the contents are replaced by the URL pointing to them.</p>
<p>Until recently, the attachments had to be sent by FTP to the web server. What&#8217;s new is that it can now be SSH instead, provided that the Net::SFTP::Foreign Perl module is installed on the server.</p>
<p>The new version of the plugin comes with manitou-mdx 1.2.0 and is named <strong>attach_uploader_ssh</strong>.<br />
(<a href="https://github.com/manitou-mail/manitou-mail-mdx/blob/master/lib/Manitou/Plugins/attach_uploader_ssh.pm">source code</a> on github)</p>
<p>To activate the plugin and connect it to a sender&#8217;s identity, it needs to be declared in manitou-mdx <a href="http://www.manitou-mail.org/doc/mdx.config.html">configuration file</a>.<br />
Example:</p>
<pre>
[mymail@domain.tld]
outgoing_plugins = attach_uploader_ssh({host=&gt;"www.myserver.tld", login=&gt;
"sshuser", base_url=&gt;"http://attached.myserver.tld", path=&gt;"/var/www/attached.myserver.tld", maxsize=&gt;2000000})
</pre>
<p>There is a &#8220;password&#8221; field that could be used but in this example it is assumed that an SSH key lets the script connect without a password. This is just one of the multiple security options and choices that open up when switching from FTP to SSH.</p>
<p>And here is how a picture larger that 2Mb would appear in the message (as a text/plain part)</p>
<pre>
The attached file is available at:

http://attached.myserver.tld/JXlafBybAKGrwE5yyOIbKA/PICT34.JPG
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2012/02/attachment-uploader-reloaded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving the source code to github</title>
		<link>http://www.manitou-mail.org/blog/2012/01/moving-the-source-code-to-github/</link>
		<comments>http://www.manitou-mail.org/blog/2012/01/moving-the-source-code-to-github/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 13:31:07 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=211</guid>
		<description><![CDATA[<p>Starting with v1.2.1 currently under development, subversion is replaced by the more modern git source control tool.</p> <p>It&#8217;s also the opportunity to split the source code into two distinct repositories for the user interface and mdx, since they can be worked on independently. A third repository should follow  for the documentation.</p> <p>The master branches for [...]]]></description>
			<content:encoded><![CDATA[<p>Starting with v1.2.1 currently under development, subversion is replaced by the more modern git source control tool.</p>
<p>It&#8217;s also the opportunity to split the source code into two distinct repositories for the user interface and mdx, since they can be worked on independently. A third repository should follow  for the documentation.</p>
<p>The master branches for both programs are accessible at:<br />
<a href="https://github.com/manitou-mail/manitou-mail-ui">https://github.com/manitou-mail/manitou-mail-ui</a> and <a href="https://github.com/manitou-mail/manitou-mail-mdx">https://github.com/manitou-mail/manitou-mail-mdx</a></p>
<p>The subversion repository at SourceForge.Net is still accessible, but from now on it will probably see commits only on releases.</p>
<p>The github service also has an issue tracker, a wiki and other things that might get used over time, we&#8217;ll see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2012/01/moving-the-source-code-to-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Version 1.2.0 released</title>
		<link>http://www.manitou-mail.org/blog/2011/12/version-1-2-0-released/</link>
		<comments>http://www.manitou-mail.org/blog/2011/12/version-1-2-0-released/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 17:34:22 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[New features]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=202</guid>
		<description><![CDATA[<p>Version 1.2.0 is now available for download. What&#8217;s new?</p> More functions are available in the filter expressions: age(), date(), date_utc(), now(), now_utc(), identity(), rawsize(). New equality and inequality operators for numeric comparisons. A mdx plugin to modify headers of outgoing mail with dynamic contents. A new incarnation of the attach_uploader plugin that supports ssh for [...]]]></description>
			<content:encoded><![CDATA[<p>Version 1.2.0 is now available for <a href="http://www.manitou-mail.org/download.php">download</a>.<br />
What&#8217;s new?</p>
<ul>
<li>More functions are available in the filter expressions: age(), date(), date_utc(), now(), now_utc(), identity(), rawsize().</li>
<li>New equality and inequality operators for numeric comparisons.</li>
<li>A mdx plugin to modify headers of outgoing mail with dynamic contents.</li>
<li>A new incarnation of the attach_uploader plugin that supports ssh for file transfers.</li>
<li>Migration to new Qt assistant and compatibility fixes for Qt-4.7 and 4.8.</li>
<li>Drag and drop for attached files in the mail composer.</li>
<li>A new dynamic column for recipients in the messages list.</li>
<li>Many improvements in the filter editor: filters can now be reordered and tested from within the interface, and the user interface for actions has been redesigned.</li>
<li>New filter actions: Set identity, set header, remove header.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/12/version-1-2-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick resend functionality</title>
		<link>http://www.manitou-mail.org/blog/2011/11/quick-resend-functionality/</link>
		<comments>http://www.manitou-mail.org/blog/2011/11/quick-resend-functionality/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 16:51:23 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Usage]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=196</guid>
		<description><![CDATA[<p>Sometimes a message that has been previously sent needs to be sent again. The normal way to do that is to recompose a new message by copying the contents of the old one. This leads to a new message with identical contents except for the Date and Message-Id header fields. However, there is a quicker [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a message that has been previously sent needs to be sent again.  The normal way to do that is to recompose a new message by copying the contents of the old one. This leads to a new message with identical contents except for the Date and Message-Id header fields.<br />
However, there is a quicker way to re-send an outgoing message without the need to create a duplicate of the original: if the Sent and Archived bit of the message status are cleared, manitou-mdx will just pick up again the message for sending as if it was new. To clear these bits, use the Message-&gt;Properties command and check No in the boxes drawn with the red border in the screenshot:<br />
<a href="http://www.manitou-mail.org/blog/wp-content/uploads/2011/11/Screenshot-Properties.png"><img src="http://www.manitou-mail.org/blog/wp-content/uploads/2011/11/Screenshot-Properties.png" alt="" width="236" height="432" class="aligncenter size-full wp-image-197" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/11/quick-resend-functionality/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acting on all tagged messages except some</title>
		<link>http://www.manitou-mail.org/blog/2011/10/acting-on-all-tagged-messages-except-some/</link>
		<comments>http://www.manitou-mail.org/blog/2011/10/acting-on-all-tagged-messages-except-some/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 20:03:30 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Usage]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=188</guid>
		<description><![CDATA[<p>Recently I wanted to reduce the size of my main manitou-mail database, and thus I&#8217;ve decided to delete all the messages I&#8217;ve received from some mailing-lists. I know these messages are archived elsewhere, so that I could re-import them if needed anyway. But I didn&#8217;t like the idea of deleting also the messages that I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wanted to reduce the size of my main manitou-mail database, and thus I&#8217;ve decided to delete all the messages I&#8217;ve received from some mailing-lists. I know these messages are archived elsewhere, so that I could re-import them if needed anyway.<br />
But I didn&#8217;t like the idea of deleting also the messages that I&#8217;ve sent to these mailing-lists, because it would have broken the rule I&#8217;ve adopted of keeping all sent messages. Also on second thought, I thought it would be best to include also the whole threads in which I&#8217;ve participated, so that the context of the messages would still be available (BTW, the entire thread to which a message belongs can be recalled in the user interface by the contextual menu command: &#8220;Show thread on new page&#8221;).</p>
<p>So the question was, how to select all the messages tagged with certain tags, but excluding all threads for which at least one message has the <em>Sent</em> status? As usual, the database and the SQL come to help. First I looked up the tag_id&#8217;s of the tags corresponding to the mailing-lists, let&#8217;s say they were 3,6 and 10. And then I just expressed in SQL the sentence above. The result is:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> mt<span style="color: #66cc66;">.</span>mail_id <span style="color: #993333; font-weight: bold;">FROM</span> mail_tags mt <span style="color: #993333; font-weight: bold;">JOIN</span> mail m1 <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>mail_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">WHERE</span> tag <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span>
 <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">FROM</span> mail m2 <span style="color: #993333; font-weight: bold;">WHERE</span> m2<span style="color: #66cc66;">.</span>thread_id<span style="color: #66cc66;">=</span>m1<span style="color: #66cc66;">.</span>thread_id <span style="color: #993333; font-weight: bold;">AND</span> m2<span style="color: #66cc66;">.</span>status&amp;amp;<span style="color: #cc66cc;">128</span>!<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>After issuing this query with the selection dialog, with the <em>Limit To</em> field empty to ensure that all messages are retrieved, all that was needed to accomplish the task was to select all the messages in the resulting list (Ctrl-A) and hit the Del key.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/10/acting-on-all-tagged-messages-except-some/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manitou-Mail for Mac OS X</title>
		<link>http://www.manitou-mail.org/blog/2011/10/manitou-mail-for-mac-os-x/</link>
		<comments>http://www.manitou-mail.org/blog/2011/10/manitou-mail-for-mac-os-x/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 22:24:30 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=172</guid>
		<description><![CDATA[<p> For you Mac users out there, I&#8217;m glad to announce that the Manitou-Mail interface is now available for Mac OS X, thanks to Adebe Networks that funded the work for the port and TLK Games who lent their Mac machine. The application bundle is available here: manitou-1.1.0.dmg (42Mb, with Qt-4.7 and libpq5 compiled with [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full alignleft" style="border: 0pt none;background-color: #ffffff;margin-top: -10px" src="http://www.manitou-mail.org/blog/wp-content/uploads/2011/10/logo-apple.png" alt="" width="96" height="116" /> For you Mac users out there, I&#8217;m glad to announce that the Manitou-Mail interface is now available for Mac OS X, thanks to <a href="http://adebenetworks.com/?lang=en">Adebe Networks</a> that funded the work for the port and <a href="http://www.tlkgames.com/">TLK Games</a> who lent their Mac machine. The application bundle is available here: <a href="http://www.manitou-mail.org/download/manitou-1.1.0.dmg">manitou-1.1.0.dmg</a> (42Mb, with Qt-4.7 and libpq5 compiled with ssl support). Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/10/manitou-mail-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Version 1.1.0</title>
		<link>http://www.manitou-mail.org/blog/2011/08/version-1-1-0/</link>
		<comments>http://www.manitou-mail.org/blog/2011/08/version-1-1-0/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 18:36:51 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[New features]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=168</guid>
		<description><![CDATA[<p>Manitou-Mail version 1.1.0 is now available. What&#8217;s new? Mostly, the mail merge capabilities for sending mailings to potentially large lists of users. Mailing templates and run-time information are stored in the database, and while the actual sending is done server-side, it can be monitored from the user interface. Mailings can be html or text only [...]]]></description>
			<content:encoded><![CDATA[<p>Manitou-Mail version 1.1.0 is now available. What&#8217;s new? Mostly, the mail merge capabilities for sending mailings to potentially large lists of users. Mailing templates and run-time information are stored in the database, and while the actual sending is done server-side, it can be monitored from the user interface.<br />
Mailings can be html or text only or both, and may use placeholders with contents imported from CSV files.</p>
<p>Additionally, the UI now uses the <a href="http://www.manitou-mail.org/blog/2011/04/word-search-in-sql/">new full text search function</a> for faster results.</p>
<p>This time, there&#8217;s a deb package for manitou-mdx that is expected to work with all reasonably recent debian/ubuntu releases, and another deb package for the user interface, which is created for ubuntu 10.<br />
See the <a href="http://www.manitou-mail.org/download.php">download page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/08/version-1-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring manitou-mdx with Nagios</title>
		<link>http://www.manitou-mail.org/blog/2011/06/monitoring-manitou-mdx-with-nagios/</link>
		<comments>http://www.manitou-mail.org/blog/2011/06/monitoring-manitou-mdx-with-nagios/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 12:46:37 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=162</guid>
		<description><![CDATA[<p>While manitou-mdx can be monitored with a stand-alone Perl program, most sysadmins prefer integrated tools such as Nagios. For those who want to monitor manitou-mdx with Nagios, the wiki now hosts a manitou-mdx plugin. It is based on the same logic than the stand-alone program: every &#8216;alive_interval&#8216; seconds as defined in its configuration file, manitou-mdx [...]]]></description>
			<content:encoded><![CDATA[<p>While manitou-mdx can be monitored with a <a href="http://www.manitou-mail.org/articles/mdx-monitoring.html">stand-alone Perl program</a>, most sysadmins prefer integrated tools such as <a href="http://www.nagios.org">Nagios</a>.<br />
For those who want to monitor manitou-mdx with Nagios, the wiki now hosts a <a href="http://www.manitou-mail.org/wiki/doku.php/mdx_nagios_plugin">manitou-mdx plugin</a>.<br />
It is based on the same logic than the stand-alone program: every &#8216;<em>alive_interval</em>&#8216; seconds as defined in its configuration file, manitou-mdx updates the &#8216;last_alive&#8217; entry in the &#8216;<em>runtime_info</em>&#8216; table. So whenever this entry has not been updated for significantly longer than &#8216;<em>alive_interval</em>&#8216; seconds, it means that either manitou-mdx is no longer running, or it&#8217;s not able to function properly for some reason that needs to be investigated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/06/monitoring-manitou-mdx-with-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing unused filters</title>
		<link>http://www.manitou-mail.org/blog/2011/05/removing-unused-filters/</link>
		<comments>http://www.manitou-mail.org/blog/2011/05/removing-unused-filters/#comments</comments>
		<pubDate>Wed, 11 May 2011 22:14:05 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Usage]]></category>

		<guid isPermaLink="false">http://www.manitou-mail.org/blog/?p=153</guid>
		<description><![CDATA[<p>For manitou-mail installations that use a lot of filters, it may be a good idea to check from time to time which ones are still useful and which ones are unused. Since all the filters are evaluated for each incoming message (except if a stop action is encountered), keeping around a large number of obsolete [...]]]></description>
			<content:encoded><![CDATA[<p>For manitou-mail installations that use a lot of filters, it may be a good idea to check from time to time which ones are still useful and which ones are unused.<br />
Since all the filters are evaluated for each incoming message (except if a stop action is encountered),  keeping around a large number of obsolete filters may have an adverse impact on CPU usage.<br />
Fortunately, manitou-mdx gathers statistics on filter hits, so it&#8217;s easy to find out which filters no longer generate any hit, with the help of some SQL.<br />
Let&#8217;s start with a query that retrieve filters that never had any hit:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> expr_id<span style="color: #66cc66;">,</span>name <span style="color: #993333; font-weight: bold;">FROM</span> filter_expr <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> filter_log <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>expr_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">WHERE</span> filter_log<span style="color: #66cc66;">.</span>expr_id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span>;</pre></div></div>

<p>Now it may be that some of the filters returned by this query are new so that no hit on them occurred yet. We need to filter out these by adding a condition on the last_update field, requesting that the filter hasn&#8217;t been modified or created as new since at least 3 months.<br />
Also, we only want entries from filter_expr that have actions tied on them, because filters without actions can be used as sub-expressions (that&#8217;s advanced filter usage) and don&#8217;t generate any hit.<br />
With these additional conditions, the query becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">DISTINCT</span> expr_id<span style="color: #66cc66;">,</span>name <span style="color: #993333; font-weight: bold;">FROM</span> filter_action <span style="color: #993333; font-weight: bold;">JOIN</span> filter_expr <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>expr_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> filter_log <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>expr_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">WHERE</span> filter_log<span style="color: #66cc66;">.</span>expr_id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AND</span> filter_expr<span style="color: #66cc66;">.</span>last_update<span style="color: #66cc66;">&lt;</span>now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span><span style="color: #ff0000;">'3 months'</span>::<span style="color: #993333; font-weight: bold;">INTERVAL</span>;</pre></div></div>

<p>With the query above we can check in advance what we&#8217;re about to delete.</p>
<p>Now, the deletion itself needs two steps, one for the filter_action table and another for filter_expr.  Since both tables are joined in the query, we need a preliminary step to save the expr_id to delete into a temporay table. The SQL sequence including the transaction is:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">BEGIN</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TEMPORARY</span> <span style="color: #993333; font-weight: bold;">TABLE</span> del_expr <span style="color: #993333; font-weight: bold;">AS</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">DISTINCT</span> expr_id <span style="color: #993333; font-weight: bold;">FROM</span> filter_action <span style="color: #993333; font-weight: bold;">JOIN</span> filter_expr <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>expr_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> filter_log <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #66cc66;">&#40;</span>expr_id<span style="color: #66cc66;">&#41;</span>
 <span style="color: #993333; font-weight: bold;">WHERE</span> filter_log<span style="color: #66cc66;">.</span>expr_id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 <span style="color: #993333; font-weight: bold;">AND</span> filter_expr<span style="color: #66cc66;">.</span>last_update&amp;lt;now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span><span style="color: #ff0000;">'3 months'</span>::<span style="color: #993333; font-weight: bold;">INTERVAL</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> filter_action <span style="color: #993333; font-weight: bold;">WHERE</span> expr_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> expr_id <span style="color: #993333; font-weight: bold;">FROM</span> del_expr<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> filter_expr <span style="color: #993333; font-weight: bold;">WHERE</span> expr_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> expr_id <span style="color: #993333; font-weight: bold;">FROM</span> del_expr<span style="color: #66cc66;">&#41;</span>;
&nbsp;
COMMIT;</pre></div></div>

<p>To additionally delete the filters that haven&#8217;t been used for a significant period of time (for example one year), they could be added to our temporary table before the above deletion:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> del_expr <span style="color: #993333; font-weight: bold;">SELECT</span> expr_id
 <span style="color: #993333; font-weight: bold;">FROM</span> filter_log <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> expr_id
 <span style="color: #993333; font-weight: bold;">HAVING</span> <span style="color: #993333; font-weight: bold;">MAX</span><span style="color: #66cc66;">&#40;</span>hit_date<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&lt;</span>now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span><span style="color: #ff0000;">'1 year'</span>::<span style="color: #993333; font-weight: bold;">INTERVAL</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Happy filters cleaning!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manitou-mail.org/blog/2011/05/removing-unused-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

