<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Zabbix_Maintenance</id>
	<title>Zabbix Maintenance - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Zabbix_Maintenance"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Zabbix_Maintenance&amp;action=history"/>
	<updated>2026-05-01T06:48:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=Zabbix_Maintenance&amp;diff=961&amp;oldid=prev</id>
		<title>Busk: Created page with &quot;``` Partitioning is the definitive answer when you have a large amount of hosts. When I was hitting about 500 VPS I was able to avoid partitioning on PgSQL running this script...&quot;</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Zabbix_Maintenance&amp;diff=961&amp;oldid=prev"/>
		<updated>2020-11-06T09:53:09Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;``` Partitioning is the definitive answer when you have a large amount of hosts. When I was hitting about 500 VPS I was able to avoid partitioning on PgSQL running this script...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;```&lt;br /&gt;
Partitioning is the definitive answer when you have a large amount of hosts. When I was hitting about 500 VPS I was able to avoid partitioning on PgSQL running this script every hour:&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
( flock -n 9 || exit 1&lt;br /&gt;
psql -U postgres zabbix -c 'DELETE FROM trends_uint t WHERE ctid IN ( SELECT t.ctid FROM trends_uint t LEFT JOIN items i ON i.itemid = t.itemid WHERE to_timestamp(t.clock) &amp;lt; (current_date - ((i.trends)::interval)) LIMIT 10000);'&lt;br /&gt;
psql -U postgres zabbix -c 'DELETE FROM history_str h WHERE ctid IN ( SELECT h.ctid FROM history_str h LEFT JOIN items i ON i.itemid = h.itemid WHERE to_timestamp(h.clock) &amp;lt; (current_date - ((i.history)::interval)) LIMIT 10000);'&lt;br /&gt;
psql -U postgres zabbix -c 'DELETE FROM history_text h WHERE ctid IN ( SELECT h.ctid FROM history_text h LEFT JOIN items i ON i.itemid = h.itemid WHERE to_timestamp(h.clock) &amp;lt; (current_date - ((i.history)::interval)) LIMIT 100000);'&lt;br /&gt;
psql -U postgres zabbix -c 'DELETE FROM history h WHERE ctid IN ( SELECT h.ctid FROM history h LEFT JOIN items i ON i.itemid = h.itemid WHERE to_timestamp(h.clock) &amp;lt; (current_date - ((i.history)::interval)) LIMIT 300000);'&lt;br /&gt;
psql -U postgres zabbix -c 'DELETE FROM history_uint h WHERE ctid IN ( SELECT h.ctid FROM history_uint h LEFT JOIN items i ON i.itemid = h.itemid WHERE to_timestamp(h.clock) &amp;lt; (current_date - ((i.history)::interval)) LIMIT 500000);'&lt;br /&gt;
) 9&amp;gt;/var/lock/00-zabbix-history-purge.lock&lt;br /&gt;
It basically purge data from the largest tables which is expired according to the item history settings.&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>Busk</name></author>
	</entry>
</feed>