Why upgrading Zabbix history tables to primary keys is a separate project
If you are upgrading a Zabbix 5.x estate, the history tables will still lack primary keys when the upgrade finishes, because the upgrade does not convert them. Converting history tables to primary keys is a manual step that you have to plan, schedule and verify on its own. Zabbix has supported primary keys on all tables, history tables included, since Zabbix 6.0 for new installations, but existing installations keep their original table layout until someone converts them. The conversion is documented in the Zabbix 6.0.0 upgrade notes, and that document is the place to start when you build the plan.
The conversion belongs in the upgrade plan, not after it, for a practical reason: history tables are usually the largest tables in the database, so the work can take long enough to change your maintenance window. If you treat it as a post-upgrade task, you may find that the server is back in production while the database is still carrying the old layout and that the conversion now competes with live housekeeping and data collection. Confirm the expected duration against your own history volume on a copy of the database, and decide in advance whether the conversion runs before or during the upgrade window.
Because the path from 5.x runs through intermediate steps, the order matters. Zabbix publishes a supported upgrade path to each LTS line, and the current LTS lines are Zabbix 6.0, 7.0 and the planned 8.0 LTS, with 6.0 limited support ending on 28 February 2027 and 7.0 LTS full support running until 30 June 2027. Check the upgrade notes for the exact version you will pass through, then include the primary key conversion as a named step in that sequence, with a rollback point and a sign-off that the table structure matches what the notes describe.
What changes in the history tables and what each change means
This table compares what changed in Zabbix history tables across releases and what each change means for an existing 5.x installation. Read it as a sequence: the primary key change is the one that needs manual work, and the support dates set how soon you need to do it.
| Change | Impact | Action needed |
|---|---|---|
| New installs from 6.0 | New installations use primary keys on all tables, including history tables. | No conversion needed on a fresh 6.0 or later install. Confirm the schema after installation. |
| Existing installs not converted | An upgrade does not convert existing history tables to primary keys automatically. | Plan a manual conversion as a separate step after the upgrade and check the 6.0.0 upgrade notes for the exact procedure. |
| History tables need manual work | Conversion is a manual database change on large tables, so it affects downtime, disk space and duplicate handling. | Estimate table sizes, check free disk space, test on a copy and confirm duplicate row handling before the production window. |
| TimescaleDB installs | History tables may be hypertables, so the conversion steps can differ from plain PostgreSQL. | Confirm the TimescaleDB extension version against the supported range and check the conversion approach with the vendor documentation. |
| License change from 7.0 | From 7.0 onward Zabbix is released under AGPLv3, previously GPLv2 up to 6.4. | Context only for this step. Review the license terms with your legal team if you distribute modified versions. |
| 7.0 LTS full support | Full support for 7.0 LTS runs until 30 June 2027. | Use this date as the target for finishing the upgrade and the table conversion on a stable schedule. |
| 6.0 LTS limited support ends | Limited support for 6.0 LTS ends on 28 February 2027, which sets the latest sensible start for a 5.x to 7.0 path. | Schedule the conversion work early enough to finish before this date, and confirm the current support terms on the life cycle page. |
How the history table conversion runs, step by step
This sequence turns a Zabbix 5.x history schema into one with primary keys in a controlled way, with a verified backup, a rehearsal on a copy, and a rollback point before each destructive change.
Confirm version and database engine
Record the exact Zabbix server version, the database engine and its version, and whether TimescaleDB is installed and enabled. Confirm which schema tables already carry primary keys so you know which history tables need conversion. Your DBA or platform engineer runs these queries against the production database and stores the output with the change record. The step is done when the version, engine and table list are written down and match what the upgrade plan assumed. Confirm the exact conversion procedure for your version and engine in the Zabbix upgrade notes before proceeding.
Inventory history tables and their size
List every history table (for example the numeric, float, string, text, log and unsigned variants), the row count of each, and the on-disk size including indexes. Check free disk space on the database volume and on the volume holding the backup target, and compare the two against the table sizes. The platform team owns this inventory and the DBA reviews the free-space assessment. It is complete when you have a table-by-table sheet and a signed-off statement that the space available covers the planned work with margin. Ask your database vendor or TimescaleDB documentation how the engine handles temporary space during a table rewrite.
Take and verify a full backup
Take a full logical or physical backup of the Zabbix database while the server is stopped or in a consistent state, following your engine's backup procedure. Restore the backup to a separate host and run a row count and a sample query against the restored copy to prove it is readable. Keep the backup offsite or on separate storage from the production volume. This is the first rollback point: the step is done when a restore has been tested and the backup is recorded as usable. Do not start any schema change until this is confirmed.
Rehearse the conversion on a copy of production
Restore the verified backup to an isolated environment with the same engine version, similar hardware and the same Zabbix server version. Run the planned conversion statements, time them against your own maintenance window, and record every error and warning. Repeat the rehearsal if you change the approach. The rehearsal is complete when two consecutive runs succeed with identical row counts and the team has an agreed runbook. Timing from the rehearsal, not from published estimates, sets the window.
Find duplicate rows that block the key
Before adding a primary key, query each history table for duplicate combinations of the columns the key will use, usually item identifier and timestamp for the history tables. Duplicates prevent the constraint from being created. Decide with the Zabbix administrator how to remove or resolve them, and record the number of duplicate rows removed per table. The check is closed when every history table returns zero duplicates on the copy and the production query results match the rehearsal. Do not delete rows on production until the rollback point in the next step is set.
Set the rollback point and run the conversion
Schedule a maintenance window with the service owners, stop the Zabbix server and frontend, and take a fresh backup immediately before the first destructive statement. Record that backup as the rollback point, with its location, checksum and time. Then run the conversion statements from the rehearsed runbook, one table at a time, checking the result after each. The step closes when every history table reports the new primary key and the server is still stopped. If any table fails, restore from the rollback point rather than attempting ad hoc fixes.
Validate row counts and query behavior
Compare row counts for each converted table with the pre-conversion inventory, allowing only for rows deliberately removed as duplicates. Start the Zabbix server and frontend, then check that history data loads in the latest data and graph views, that trigger evaluation runs, and that housekeeping and history queries complete without errors in the server log. Compare the timing of a few representative queries with the rehearsal. The step is done when the counts reconcile, the logs are clean for an agreed observation period and the service owner signs off.
Close the change and keep the evidence
Store the inventory, backup and restore test records, duplicate removal counts, conversion output, validation results and sign-off in the change record. Keep the rollback backup for the retention period your change policy requires before deleting it. Update the operations runbook so later upgrades and housekeeping account for the converted tables. The change is closed when the evidence package is complete and the team has confirmed that the rollback backup is no longer needed or has been archived.
What to prepare before touching the history tables
Conversion rewrites the largest tables in your Zabbix database, so the preparation work decides whether the change is a planned window or an incident. The items below cover recovery, capacity, data quality, engine support and agreement, and each one should be closed before anyone runs a conversion statement.
Verified backup and restore test
Take a full database backup and restore it to a separate host to confirm it is usable. A backup that has never been restored is an assumption, not a rollback plan. Record how long the restore took, because that figure is your realistic worst case if the conversion fails part way. Confirm that the backup includes the TimescaleDB objects if you run that extension.
6.0.0 upgrade notesFree disk space for rewritten tables
Converting a history table to a primary key rewrites it, so the database needs free space roughly comparable to the size of the largest history table while the change runs. Measure current table and index sizes, then compare them with free space on the data volume and the write-ahead or transaction log volume. Ask your DBA to confirm the figure for your engine rather than relying on a general rule.
Production-sized test copy
Build a copy of the production database with the same row counts, partitioning and extensions, then run the conversion there first. Timing on a small lab database says little about a history table holding years of values. Record the duration per table and the peak disk use so the production window is based on measured numbers, not estimates.
Duplicate row check
Count rows that share the same key columns in each history table before adding a primary key, because duplicates block the constraint. Decide in advance whether you will remove them, and how, since deleting history is permanent. Keep a record of the counts so you can show stakeholders exactly what was changed and why.
Agreed maintenance window
Agree a window with the teams that depend on Zabbix, including on-call staff, the service owners who rely on alerts, and anyone responsible for proxies that buffer data during downtime. Set the window from the test copy timings plus a margin, and name who can call a rollback and by when. Confirm how monitoring gaps will be explained and recorded.
Engine and TimescaleDB version record
Record the exact database engine version and, if used, the TimescaleDB extension version, then compare both with the supported ranges in the Zabbix requirements for your Zabbix release. Confirm this against the version you will run after the upgrade, not only the current one. Any mismatch should be resolved before the window, not during it.
Zabbix requirementsHow TimescaleDB and disk space change the conversion
The main difference on a TimescaleDB-backed installation is that the history tables are hypertables, so the conversion has to be checked against the extension as well as against PostgreSQL. Confirm in the Zabbix documentation for your exact release how the primary key change is applied to hypertables before you schedule anything, because chunked storage affects how the table is rewritten and how long it holds locks. Also confirm that your TimescaleDB extension version sits inside the range Zabbix supports for your target release. For Zabbix 7.4 that range is 2.13 to 2.29, so an extension version outside it is a blocker to resolve first, either by upgrading the extension within the range or by planning a separate change. Check the version with your database administrator and record it in the change plan.
Rewriting large history tables needs spare disk space, and the amount depends on the size of your own tables, indexes and the rewrite method the extension and Zabbix use. Do not assume a figure from someone else's environment. Measure the total size of each history table and its indexes, including the chunks, and compare that with the free space on the database volume and the write-ahead log location. Keep a safety margin for the rewrite and for the backup you take before starting. Ask Zabbix support or your vendor contact to confirm the expected temporary space for your version, and then prove it in a rehearsal on a restored copy of production. A rehearsal on a copy that holds the same table sizes and extension version will show the real space curve and the real duration, which no general guidance can provide.
Handling duplicate rows that block the primary key
A rehearsal on a restored copy of production is the cheapest place to find duplicate rows. Duplicates in history tables usually come from identical item, clock and value combinations written more than once, for example after collector retries or time-stamp collisions. The rehearsal result sets the decision for production, so the team should record every duplicate pattern it finds rather than only the total count.
- Profile before deleting: Group candidate duplicates by
itemidandclockand note whether thevaluecolumns match, so you know which rows are exact copies and which only share a timestamp. - Choose one decision per pattern: Remove exact copies, keep one row where values differ only by collection noise, or reconcile conflicting values with the data owner. Write the decision next to each pattern.
- Get sign-off from the platform owner and the monitoring owner: The platform owner accepts the data loss risk and the monitoring owner confirms that no dashboard, trigger or report depends on the rows being removed.
- Record row counts before and after: Count rows per history table, per item group and per time range before the cleanup, then repeat the same counts after the cleanup and confirm the difference equals the number of rows you intended to remove.
- Time the rehearsal cleanup: Measure how long the removal and the key creation take on the copy, so the production change window is based on a measured run and not an estimate.
Check that the rehearsal counts match the decisions in writing before production work is scheduled.
Duplicates that appear only in production are the higher risk case. The rehearsal copy may be older, may lack recent collection activity, or may have been pruned by housekeeping, so the production data can contain rows the team has never seen. The team should not run a bulk delete unplanned during the change window. Stop, count, classify and decide first.
- Freeze writes before counting: Pause the affected collectors or stop the server for the counting step, so the counts are not moving while you measure them.
- Keep a full backup before any delete: Take a verified backup of the history tables that will be changed, and confirm you can restore it, before the first row is removed.
- Separate remove from keep by business rule: Agree in writing which rows are safe to remove, which must be kept, and which need the data owner to decide. Auditors often ask for this list.
- Sign off by two roles: The database owner signs the technical plan, and the security or compliance owner signs any decision that removes data that might be evidence of an incident.
- Compare totals and samples afterward: Check total row counts against the pre-change figures, plus a sample of items and time ranges, and confirm the Zabbix frontend still shows the expected history.
If the counts do not reconcile with the decision log, stop and restore from the backup rather than continuing the change.
Installations that partition history tables or use TimescaleDB compression need different handling. Duplicate checks and deletes on compressed chunks can be slower and behave differently from plain tables, and the primary key work may interact with partitioning or compression settings. The team should confirm the exact behavior of its own database version and TimescaleDB version before planning the change, using the Zabbix requirements and the TimescaleDB documentation for those versions.
- Identify the chunks in scope: List which partitions or compressed chunks contain candidate duplicates, so the work can be limited to them and the rest of the table is left untouched.
- Decompress only what you must: If compressed chunks hold duplicates, plan how they are decompressed, how long that takes and how much disk space it needs, and test this on the rehearsal copy first.
- Check the key definition against partitioning: Confirm that the key definition the upgrade needs is compatible with the partitioning scheme in your database, and record any constraint that differs from the default.
- Assign the database owner as decision maker: Because the choice affects storage layout and retention, the database owner signs the plan and the monitoring owner signs the retention impact.
- Verify chunk-level counts: Count rows per chunk before and after, not only per table, so you can prove that removals stayed inside the intended time ranges.
Confirm the TimescaleDB and database versions in your environment before any step runs, because the supported combinations are listed in the Zabbix requirements.
Across all three situations the same evidence trail is what makes the decision defensible. The duplicate report, the decision for each pattern, the approver for each decision and the before and after counts should live in one change record. Compliance reviewers and the next operator rely on this record, and it is the fastest way to answer questions about why a row is missing.
- Keep one decision log: Each duplicate pattern gets an ID, a count, a decision (remove, keep or reconcile), a reason and a named approver.
- Store counts with timestamps: Save the before and after counts in the change record with the time they were taken and the database name they came from.
- Retain the backup reference: Record where the pre-change backup is stored and how long it is kept under your retention policy.
- Name the approvers by role: Use roles such as database owner, monitoring owner and security or compliance owner, with the person's name attached in your own change system.
- Schedule a follow-up check: Plan a check after the next housekeeping cycle to confirm that duplicates did not return from collectors that were not fixed.
Before closing the change, confirm that the decision log, counts and approvals match, and that the backup reference can be restored.
What makes the conversion take longer
This table lists the factors that stretch the history table conversion window, why each one matters, and what to measure before you schedule downtime. Read it before estimating the window with your team, because most of the drivers are visible in your database today.
| Driver | Why it matters | What to check |
|---|---|---|
| History table size | Conversion rewrites the full contents of each history table, so the amount of stored history is the main load on the window. | Row counts and on-disk size of the history tables, and the retention settings that control how much history is kept |
| Database engine and TimescaleDB use | The conversion runs differently on MySQL, MariaDB and PostgreSQL, and hypertables add chunk handling that changes the steps. | Engine and version, whether TimescaleDB is installed, and whether the history tables are hypertables |
| Free disk space | Rebuilding tables needs temporary space alongside the existing data, so a tight disk can stop the job partway. | Free space on the database volume and on the WAL or binary log volume, measured against the size of the largest history tables |
| Duplicate rows | Primary keys cannot be created while duplicate rows exist, so duplicates must be found and removed first. | Whether any history table already has repeated itemid and clock combinations, checked on a copy of the database |
| Item count and write rate | A high write rate creates more rows during the window and a larger backlog to catch up on once Zabbix restarts. | Number of enabled items, the new values per second reported in server internal metrics, and how many items are in the queue |
| Zabbix server nodes | Every node that writes to the database during the conversion can block the change or add new rows while it runs. | How many server nodes share the database, which ones must be stopped, and whether any proxy or frontend will still write |
How the conversion phases and rollback points fit together
The conversion starts with a verified backup and a rehearsal on a copy of the database, so the team learns how long each history table takes before touching production. Duplicate rows are checked and resolved before the maintenance window opens, because duplicates block the primary key change. After conversion, validation decides the outcome: a pass closes the change, while a failure sends the team back to the backup. Check each rollback point before you start, since the backup is the only path back.
Conversion phases with the rollback branch to the verified backup.
Questions teams ask before converting Zabbix history tables
What does converting Zabbix history tables cost?
The cost is mostly labor and time, not a license. Zabbix open source has no license fee, so the spend is the people doing the conversion, the staging environment you test on, and any spare storage you need during the change. Costs rise with the size of the history tables, how many history tables and item types are involved, how many copies of the database you must keep for testing and rollback, and how much verification your change process requires. A fixed-scope quote from DeployOpen follows from a written scope that names these inputs. Ask any vendor to itemize one-time work separately from any recurring support you may add afterwards.
How long will the Zabbix downtime be during conversion?
Downtime depends mainly on how many rows the history tables hold and how fast your database server writes them during the rebuild. The conversion rewrites data, so the server and frontend should be stopped while the change runs, and the time grows with table size, disk throughput, indexes and whether TimescaleDB chunks must be handled. Measure it on a copy of your production database before you set a maintenance window. Your own timing from that test is the only reliable figure, so ask your team or a partner to run the conversion on a restored copy and record elapsed time per table.
What do we need to provide before the conversion starts?
You need to provide access and facts about your environment. The typical list includes the current Zabbix version and database engine with version, the database size and row counts for the history tables, a recent verified backup, a staging host or restored copy with similar hardware, free disk space that you can confirm before the change, the maintenance window approved by your change board, and named contacts who can approve a rollback decision. Your team also needs to confirm which hosts and proxies feed the server, since data collection continues during preparation. Put these inputs in writing so the scope and timing in the quote match your actual system.
Can our internal team convert the history tables without a partner?
Yes, if your team has database administration skills and time to test. The Zabbix 6.0.0 upgrade notes describe the change, and a capable DBA can follow them on a copy of the database. The main questions to answer honestly are whether you have someone who has done this before, whether you can test on a full-size copy, whether the team can stay on call during downtime, and who signs off on a rollback. A partner adds independent planning, a rehearsal, and documented evidence. Either way, the work is a one-time change, so weigh the cost of staff time against the risk of a failed conversion during a production window.
How should we test rollback before converting history tables?
Test rollback on a restored copy of production before the real window. Take a full database backup, confirm that you can restore it to a separate server, run the conversion there, and time how long the restore takes. Also verify that the restored database starts the same Zabbix version and that data looks correct. Record the restore time, because it sets the point after which rollback is no longer practical. Agree in writing who makes the rollback decision and at what time. Ask whichever team performs the work to show the test results, including failed attempts and fixes.
What goes wrong with duplicate rows during the conversion?
Duplicate rows block the primary key from being created, because the key requires each row to be unique. Duplicates usually come from repeated writes of the same item and timestamp, often after a failover, a restarted process or a proxy resend. Before converting, count duplicates per history table using queries against the item and clock columns, decide whether to keep one row or remove the extra rows, and document the rule. Removing rows changes your historical data, so the decision should be approved by the data owner. Check the Zabbix 6.0.0 upgrade notes for the exact columns the key uses in your version.
How much disk space does the conversion need?
The conversion needs free space for a rebuilt copy of each history table plus the new index, and the space must be available before the change starts. Check the size of each history table, its indexes and the database's free space, then leave room for the temporary copy and for write-ahead or transaction logs. The exact requirement depends on your database engine, the table layout and whether TimescaleDB hypertables are involved. Confirm the figure with your database administrator on a copy, because estimates from general guidance can differ from your data.
Does TimescaleDB change how we convert history tables?
Yes, TimescaleDB stores history in chunked hypertables, so the conversion must respect chunk layout, compression settings and retention jobs. Check whether compression or retention policies run during the window, and pause them only as your runbook allows. Confirm the TimescaleDB extension version against the Zabbix requirements for your release before you start, and rehearse the exact statements on a copy. Ask the person doing the work to show how they handled chunks in the test, because a generic approach may not match your setup.
When a support subscription or retainer helps
Open-source Zabbix carries no license fee, no device limits and no feature gates, so the decision about paid help is about operational risk, not software cost. Zabbix sells technical support subscriptions in Silver, Gold, Platinum, Enterprise and Global tiers, and the response times run from 8x5 coverage with a 1 day response at Silver, through 4 hour response at Gold, to 24x7 coverage with 2 hour (Platinum), 1.5 hour (Enterprise) and 1 hour (Global) response. Before you buy, confirm on the Zabbix support page which tier matches your hours, your severity definitions and whether the tier covers the database engine you run, since a history table conversion on TimescaleDB or PostgreSQL may need a different kind of help than a server fault.
A vendor subscription is most useful as a safety net around the conversion window rather than as the project itself. It gives you a route to escalate if the ALTER TABLE or index build stalls, if replication lag appears during the change, or if a duplicate-row cleanup behaves differently on your data than the documentation suggests. The conversion is a one-time task for each installation, so a subscription bought only for this work is hard to justify on its own. Ask whether the subscription can be bought for a defined period that covers the maintenance window and your post-upgrade checks.
A planned engagement is the better fit when the work is a sequence of checks you want done once, in writing, with evidence: a rehearsal on a restored copy, timed runs, a rollback plan and a sign-off record for your change board. Ongoing upgrades, regression testing of templates and periodic checks of housekeeping and history growth can run as a retainer, with scope, response expectations and deliverables agreed in writing before work starts. Ask any partner to state which of these items is one-time, which recurs, and what each costs to change if the Zabbix release line moves forward.
How DeployOpen scopes and delivers the history table conversion
DeployOpen treats the history table conversion as a planned change to a live monitoring database, not a single command run at the end of an upgrade. We scope it in writing, rehearse it on a copy of your data, and hand over the procedure and checks your own team will use.
How we scope
- Engagements are fixed-scope, with the conversion, its test copy and its checks agreed in writing before work starts.
- We inventory your history tables, row counts, retention settings and database backend so the conversion effort reflects your real estate.
- We confirm the maintenance window, free disk space and the rollback point with your operations team before any step runs.
- Scope states which Zabbix version you are moving to and which database engine and TimescaleDB version are involved.
How we build
- We run the conversion first on a restored copy of production, timing each table so the window you request is based on evidence.
- We check for duplicate rows in history tables before adding primary keys and agree with you how any duplicates are handled.
- We prepare the database steps for your backend, including the TimescaleDB-specific steps when hypertables are in use.
- We verify server startup, history writes, trend data and frontend graphs against the upgraded copy before production is touched.
How we hand over
- You receive the tested conversion procedure, the pre-checks, the post-checks and the rollback steps as written documents.
- Documentation records the measured durations, disk usage observed during the rehearsal and the exact versions tested.
- We walk your database and Zabbix administrators through the runbook so they can repeat or audit the change themselves.
- Handover includes a list of items to confirm with your auditors or internal assurance team, such as backup and change records.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after the conversion is complete.
- A retainer can cover monitoring of database growth and housekeeping settings in the period after the change.
- Support can extend to the next Zabbix LTS upgrade, so the history table work is not repeated from scratch.
- Ask any provider to confirm response times and coverage in writing, since these vary with the agreed contract.

