Troubleshooting
Why Ignition tag historian drives SQL Server to 100% CPU
Short answer
The question marks in the historian's TOP 1 query are JDBC parameter markers, not a syntax error. The load is the per-execution cost of boundary lookups against a monthly partition holding tens of millions of rows with fragmented indexes. Rebuild the indexes, size partitions to about ten million rows (one week at the measured rate), and raise deadband on the heaviest tags.
On this page
- Is the historian query with the question marks broken?
- Does the load follow the historical tag provider?
- How many rows are in the active partition table?
- Are the indexes fragmented enough to explain the CPU?
- What logging rate fills a partition?
- Why does the Ignition gateway page when RAM is free?
- How do I fix it and bring the historian back?
- How large can a partition get before the CPU climbs again?
- Questions asked
A dedicated SQL Server sat pinned at 100% CPU, and the load tracked the Ignition historical tag provider: with the provider disabled the processor fell back to its normal profile, and enabling it reproduced the saturation on demand. The most expensive statement in every trace was the same TOP 1 lookup against the March partition table, question marks included, and those question marks are not a fault. The cause is the cost of that lookup against a monthly table holding tens of millions of rows with fragmented indexes. The repair is to rebuild the indexes, cut the logging volume on the heaviest tags, and shorten the partition length. Work the checks below in order; each one names the reading to take and where to go next.
Is the historian query with the question marks broken? #
No. The question marks are JDBC parameter markers: the historian sends prepared statements, and the query-stats view shows the parameterized text, so some logged copies carry substituted values and some carry the markers. The statement, as the query stats show it:
SELECT TOP 1 "tagid","intvalue","floatvalue","stringvalue","datevalue","t_stamp","dataintegrity"
FROM sqlt_data_1_2017_03
WHERE "tagid" IN (?,?) AND "t_stamp" < ?
ORDER BY "t_stamp" DESC
It is a boundary lookup, the kind the historian's query machinery issues constantly while trends and history reads are served. Reading to take: this statement's execution count and total worker time, with the query stats sorted by total worker time. Outcome: if this one text dominates total CPU with a high execution count, the problem is cost per execution against the table, not broken SQL. Go to the provider toggle next.
Does the load follow the historical tag provider? #
In the reported case, yes: disabling the provider in the gateway web interface dropped SQL Server CPU to its normal profile at once, and re-enabling it reproduced the 100% load, with no server configuration change in between. Toggle it yourself and watch the processor each way; the normal profile in that case was peaks near 60% with long idle stretches.
| Reading | Meaning | Next check |
|---|---|---|
| CPU falls on disable and returns on enable | The historian workload is the trigger | Row count of the active partition |
| CPU stays high with the provider disabled | Another client or a maintenance job is the load | Rank all sessions' queries by total worker time |
| The same statement text dominates with a high execution count | Cost per execution on a large table | Index state and row count |
The MES on the same server executed roughly ten times the historian's reads and writes and never produced the spike, which rules total client volume out as the driver. Keep the provider disabled while you work through the checks, so the other SQL clients keep the database to themselves. If the processor that climbs belongs to the Ignition gateway rather than the database, that is a different fault, and fixing Ignition Core Historian high CPU usage covers it.
How many rows are in the active partition table? #
Count the rows in the current and previous partition tables: the case that failed held 23 million rows in its March table and 32 million in February under monthly partitioning, and tens of millions of rows in one table is where boundary lookups stop being cheap. The larger February table ran without incident, so row count alone did not explain why March tipped over, but size sets how expensive every lookup can get. Decide from the count:
- Tens of millions of rows in the active table: shorten the partition length, monthly to weekly or shorter, so every new table starts small and each lookup stays inside a smaller index. The setting lives with the historian settings of the database connection the historian writes through.
- Low millions or fewer: table size is not the driver; go to the index check.
Are the indexes fragmented enough to explain the CPU? #
Measure fragmentation on both monthly tables before changing anything: in the reported case the levels were similar in both, so fragmentation was a contributor that turned expensive once table size and lookup rate climbed, not the trigger by itself. Fragmentation is a known weak point for historian tables on SQL Server, because rows arrive across many tag IDs, inserts scatter through the index, and page splits accumulate. The defragmentation still cut the load noticeably once it had run for a while in that case, so treat it as a real corrective step, just not the whole cure.
| Reading | Cause | Action |
|---|---|---|
| Heavy fragmentation on a large index | More pages read per lookup and maintained per insert | Rebuild or reorganize the indexes on the active tables |
| Similar fragmentation on a table that never caused trouble | Fragmentation is a contributor, not the trigger | Also shrink partitions and logging volume |
| CPU climbs again days after a rebuild | The table keeps growing and re-fragmenting | Shorter partitions and a lower logging rate |
Plan the rebuild for a window with the provider disabled, so the other SQL clients keep normal response while it runs.
What logging rate fills a partition? #
The case site wrote about 60,000 rows per hour, steady over time, so a rate spike was not the cause; volume still sets how fast each partition grows, and that is the number that sizes the partition length. Count the rows written in a representative hour, for example by grouping the current partition's rows on the hour of their timestamps. Worked example at that measured rate, illustrative arithmetic:
- One week: 60,000 rows per hour × 168 hours = 10,080,000 rows
- One 30-day month: 60,000 rows per hour × 720 hours = 43,200,000 rows
A monthly partition therefore grows to roughly 43 million rows at this rate, while a weekly one stays near 10 million, and the failing case lived in the first range. To cut volume without losing useful history, three settings move the number:
| Change | Where it lives | Effect |
|---|---|---|
| A larger deadband | The per-tag historian settings | Fewer rows from slowly moving analog values |
| A longer minimum time between logging | The per-tag historian settings | Caps the write rate of noisy tags |
| A shorter partition length | The historian settings of the database connection | Smaller tables and smaller indexes per lookup |
In the reported case both tag-level changes went to the tags that logged most heavily, so future partitions come out smaller before the partition length is even touched.
Why does the Ignition gateway page when RAM is free? #
Pagefile reads and writes on the gateway dropped sharply whenever the historian was stopped, although physical RAM was not short: slow, CPU-bound lookups keep work queued in the gateway longer, so the paging is a downstream symptom of database slowness, not a memory fault. Take the reading before the fix: record the gateway's process memory and pagefile input and output with the historian running, then record the same counters after the SQL-side repair. If paging stays high while SQL Server CPU is back to normal, compare the gateway's configured maximum heap with the memory actually available on its host, and adjust that limit in the gateway's service configuration.
How do I fix it and bring the historian back? #
Work the repair in this order: with the provider still disabled, rebuild or reorganize the indexes on the current and previous partition tables, then raise deadband and lengthen minimum time between logging on the heaviest tags, shorten the partition length, and re-enable the provider.
- Leave the historical tag provider disabled and confirm SQL Server CPU holds its normal profile.
- Rebuild or reorganize the indexes on the current and previous partition tables, in a planned window; this is the defragmentation step from the index check.
- Raise the deadband and lengthen the minimum time between logging on the highest-volume tags; how Tag Historian deadband compression picks stored points explains which rows the deadband keeps and drops.
- Shorten the partition length in the database connection's historian settings so new tables start small, and apply the site's retention and pruning policy to the oversized tables already there; cutting Tag Historian growth before compressing the table shows where the volume really goes.
- Re-enable the historical tag provider and watch the CPU and the per-execution cost of the TOP 1 statement for the first days.
How large can a partition get before the CPU climbs again? #
Size each partition to about 10 million rows: at the case site's measured rate that is one week, and it keeps every table below the tens-of-millions range where the boundary lookups turned expensive on this hardware. Derive the length from your own measured rate: partition length in hours = 10,000,000 rows ÷ your measured rows per hour. Worked at the case rate: 10,000,000 ÷ 60,000 ≈ 167 hours, which rounds to the one-week partition, comfortably under half the 23 million rows the smallest monthly table that caused trouble held. Then verify on your hardware: as a partition grows, track the TOP 1 statement's average worker time per execution against the partition's row count. If that average starts climbing before a partition reaches the target, shorten one step further, down to daily partitions if it persists. If it stays flat well past the target, the hardware has headroom and the current length stands. On a shared or smaller SQL Server host, expect the curve to bend earlier and begin with weekly partitions, not monthly.
Questions asked
Why did the bigger February table run without trouble while March saturated the CPU?
Row count alone did not tip the server. The active partition absorbs the inserts and the boundary lookups at the same time, while a closed table mostly serves occasional range reads. Cost per lookup on the March table kept rising as rows and page splits accumulated, until total worker time saturated the CPUs; the closed February table at 32 million rows never carried that combined load.
Is history lost while the provider is disabled?
The historian stops collecting, so the disabled period becomes a gap in the history tables, and nothing backfills it afterwards. Keep the disable as short as the repair allows, or schedule the rebuild in a low-production window. The trade is deliberate: the MES and other SQL clients get normal response while the historian is out of the way.
Which tags should get the deadband change first?
Rank by volume: count rows grouped by tag ID in the current partition and work the top contributors. Noisy analog tags with tight deadbands usually dominate the total. Widen the deadband so only meaningful moves store a row, and lengthen the minimum time between logging to cap the rate; retuning five heavy tags removes more rows than touching fifty quiet ones.
Can the index rebuild run while history logging continues?
It depends on the SQL Server edition: an online rebuild keeps the table readable, while an offline rebuild locks it and blocks both the historian's inserts and history queries for the duration. Check the edition before planning the job. Either way, the rebuild belongs in a window with the provider out of the way.
What readings confirm the fix held?
Watch three numbers for several days after re-enabling the provider: SQL Server CPU holding its normal profile, the TOP 1 statement's average worker time per execution sitting well under the pre-rebuild value, and gateway pagefile input and output back at its baseline. If the per-execution average climbs again as a partition grows, shorten the partition length one more step.