IMD SolutionComputing LibraryShop main store

Troubleshooting

Historian 2017 INNER REMOTE JOIN returns one tag's values

Edge computing and IIoT Published 8 min read By IMD Solution engineering team

Short answer

The 17,280-row result is one tag's complete averaged day at wwResolution 5000, so the surviving tag is intact and the remote join dropped the other 34 during execution. Compare one-tag, bounded-list and joined queries with identical bounds and retrieval options, then deploy an IN list or per-tag UNION retrieval and report the exact build to the vendor.

On this page
  1. Why does my Historian 2017 remote join return only the first tag?
  2. Does the tag list table contain the 35 tags I asked for?
  3. Does one tag return its full day when queried on its own?
  4. Does the fault follow the tag list or the remote join itself?
  5. Which query shape replaces the failing remote join?
  6. What does a complete one-day result set look like?
  7. How do I confirm a version fault before deploying the fix?
  8. Questions asked

An INNER REMOTE JOIN against a historian that returns one tag's complete averaged day — and nothing from the other 34 selected tags — is a query-execution fault, not missing data. The row count gives it away: one day divided by the five-second resolution is exactly one tag's worth of averaged points, so the surviving tag is intact. Isolate the fault with three matched queries — one tag directly, a bounded tag list directly, then the original join — using identical time bounds and retrieval options throughout. Then replace the join with a bounded tag-name filter or per-tag retrieval, verify the returned tag names and row counts, and take the exact historian build to the vendor, because this query shape has been reported as version-specific.

Why does my Historian 2017 remote join return only the first tag? #

Because 17,280 rows is exactly one 24-hour day divided by the 5-second resolution (86,400 s ÷ 5 s), the tag that came back is complete, and the other 34 were dropped while the query executed, not by the tag filter.

Worked example, using the reported query's own settings. The window runs from midnight on 20 June to midnight on 21 June, assuming midnight-to-midnight in the historian's own time context, so the query period is 24 h × 3600 s/h = 86,400 s. The historian's documentation defines resolution so that the rows a query returns equal the query period divided by the resolution; at wwResolution = 5000 ms that is one row every 5 s per tag, and 35 tags over the same window would return 35 × 17,280 = 604,800 rows. A result holding exactly the per-tag count for a single tag name is a complete single-tag day, not a partial export.

The mechanics are worth naming. wwResolution and wwRetrievalMode are temporal extension options that the historian itself reads; SQL Server does not evaluate them as ordinary predicates. With no tag-name restriction inside the retrieval, a remote join gives the execution engine room to build averaged series for far more tags than the report needs and keep only what matches afterwards — which is consistent with a result in which one tag survives intact and the rest vanish. Treat the single-tag result as a remote temporal-join fault until the tests below prove otherwise; it is not, on its own, evidence that the other tags stopped recording or that the filter matched one row.

One caution before you reproduce anything: a history retrieval with no tag restriction computes series for every tag in the historian, so on a system with thousands of tags an open-ended query can generate tens of millions of rows and put real load on the historian host. Bound the tag set in every test query.

Does the tag list table contain the 35 tags I asked for? #

Run the selection query on its own and record the actual tag names, because 35 rows proves only a count: duplicated names, stray whitespace, spelling differences or names that do not exist in the historian would each survive that count and break the join downstream.

SELECT *
FROM [SSRS].[dbo].VerbruikRapport
WHERE VerbruikSoort = 'Utility_5';

Compare the raw row count against a count of distinct tag names, and compare the names themselves against the historian's tag list; the names that come back are the reference set for every later test. If the distinct count is lower than the row count, or any name looks wrong, correct the source table first — a fault here masquerades perfectly as a join fault. If the names are sound, copy one for the single-tag test and set two or three aside for the bounded-list test.

Does one tag return its full day when queried on its own? #

Query one recorded tag straight from Runtime.dbo.History with the same half-open window, the same wwResolution and the same wwRetrievalMode; a full per-tag result proves the tag and the temporal request are sound and keeps the join as the only suspect.

SELECT h.TagName, h.DateTime, h.vValue
FROM Runtime.dbo.History h
WHERE h.TagName = 'UtilityMeter_01' -- example name; use one recorded from VerbruikRapport
  AND h.DateTime >= '2020-06-20'
  AND h.DateTime < '2020-06-21'
  AND wwResolution = 5000
  AND wwRetrievalMode = 'Average';

Keep the exclusive upper bound exactly as reported: DateTime < '2020-06-21' leaves midnight of the following day out of the window, and changing the bounds between tests changes the expected row count and blurs the comparison. If the direct query returns the full per-tag count, the retrieval side is proven and the join stays the only suspect. If it returns nothing while the tag is clearly live in the running system, the fault sits upstream of the join entirely — the same live-versus-stored split appears in why Ignition historian tags stop recording while live data stays good.

Does the fault follow the tag list or the remote join itself? #

Three queries with identical time bounds and identical retrieval options decide it: one tag directly, a short tag list directly, then the original join; whichever step first loses tags names the failing layer.

  1. The single tag fails directly. The fault is the tag or its stored history, not the join — settle registration and coverage before testing anything else.
  2. The single tag passes but a short direct list returns one tag. The multi-tag temporal query itself is implicated on this build; move to the replacement shapes below and validate them on two or three known names.
  3. The short direct list passes but the original join returns one tag. The remote join execution is at fault; replace the join, keep the saved query as a regression test, and take the build number to the vendor.

That is the same discipline as any query-layer diagnosis: a result that is structurally valid but wrongly shaped points at the query, the same class of problem as a C# historian REST query that returns an empty grid. Prove the request, then the transport, then the combination, in that order, and change one variable at a time.

Which query shape replaces the failing remote join? #

Hand the historian a bounded tag-name filter instead of letting a join assemble the tag set — an IN list built from the names you recorded — or retrieve each tag separately and combine the result sets with UNION, keeping the window and retrieval options identical in every branch.

SELECT h.TagName, h.DateTime, h.vValue
FROM Runtime.dbo.History h
WHERE h.TagName IN ('UtilityMeter_01', 'UtilityMeter_02', 'UtilityMeter_03') -- example names
  AND h.DateTime >= '2020-06-20'
  AND h.DateTime < '2020-06-21'
  AND wwResolution = 5000
  AND wwRetrievalMode = 'Average';

Validate the IN shape first on two or three known names with the original temporal options, and confirm that your installed version documents it before scaling to the full name list. The point of the filter is to bound the retrieval side to exactly the intended tags, instead of computing series for the whole historian and discarding them at the join.

The other shape moves the tag list into a stored procedure: one query branch per recorded tag, every branch carrying the same window, the same wwResolution and the same wwRetrievalMode, and each SELECT keeping TagName so every value stays attributable. Validate it on two or three tags the same way. Both shapes avoid the failing join, and neither asks the historian to compute rows for tags the report will never use.

If the data ends up in a client rather than in SQL, the same bounding discipline applies when you query tag history from a remote tag provider: name the tags in the request, fix the window, and let nothing downstream decide which tags survive.

What does a complete one-day result set look like? #

For this case a complete result carries 35 distinct tag names and 604,800 rows in total — 35 × 17,280 — so two checks decide acceptance: the distinct TagName count must match the selected tag count, and each tag's row count must match the per-tag count for that window.

  • Distinct TagName count equals the number of names recorded from the source table.
  • Each tag's row count equals the per-tag count, scaled down only for a tag that begins or ends inside the window.
  • Every row keeps its TagName, so any value traces back to its tag and timestamp.
  • One known tag, value and timestamp is spot-checked against a trend in the historian client before the report goes back into service.

Per-tag counts also catch partial coverage: a collector outage, a tag renamed mid-window or a commissioning gap shows up as one tag below its expected count while the rest are complete. Settle that before blaming the query, because a complete-looking total can hide one short tag.

How do I confirm a version fault before deploying the fix? #

Capture the exact historian build and the original query's results, then take both to the vendor: the reported case was reproduced on 2017 and ran correctly on other versions, so any fix will be tied to that specific build, not to the query shape.

Record the historian version and build, the operating system patch level of the historian host, the original query text, its result count and its distinct tag names, and the same set for every isolation test. Then check the vendor's known-issues notes for that exact build before installing anything: version-specific faults are documented together with vendor-documented workarounds, and an unrelated update installed on the strength of another version's behavior proves nothing about yours.

  • Save the original join and its one-tag result as the regression test.
  • Promote the bounded IN list or the per-tag UNION retrieval to production only after it passes the short-list validation and the full-count checks.
  • After any vendor fix, rerun the complete date range and compare the distinct returned tags against the recorded name list before the report goes back into service.

The decisions, case by case. Single-tag query fails: fix the tag and its stored history first, and leave the join out of it. Single tag passes but a short direct list fails: bound every retrieval with an explicit tag list on this build. Only the join fails: replace it with the IN or UNION shape, verify the full distinct-tag count and the per-tag counts, and report the build to the vendor for a version-specific correction. Everything passes after a vendor fix: rerun the saved original join once as a regression test before retiring the workaround.

Questions asked

What does the REMOTE keyword actually change in the join?

REMOTE is a join hint that tells SQL Server to run the join work on the remote server instead of pulling the whole remote table across the network. With a historian it matters because the temporal options such as wwResolution and wwRetrievalMode are read by the historian itself, so where the join executes affects how those options are applied. Keep the hint identical across every comparison test, and change one thing at a time.

How many rows should the same query return for a shorter window?

Multiply the window length by the tag count and divide by the resolution. As a calculated example: an eight-hour window is 28,800 s, and 28,800 s divided by 5 s gives 5,760 rows per tag, so all 35 tags return 201,600 rows when each covers the full window. A tag that reports for only part of the window returns proportionally fewer rows, so judge per-tag counts against each tag's actual coverage rather than against one overall total.

Should I keep the remote join in case a hotfix changes its behavior?

Keep the original join only as a saved regression test. Until a fix for your exact build documents corrected behavior, the bounded IN list or the per-tag UNION retrieval is the query to run in production, because both are validated against known tag names and expected row counts. If the vendor ships a build-specific fix, rerun the saved join, compare distinct tag names and row counts against the working query, and only then retire the workaround.

Why does the exclusive upper bound matter for the row count?

The window is half-open: DateTime must be on or after 20 June and strictly before 21 June. The strict bound keeps midnight at the start of the following day outside the window, so exactly one day of data, meaning one row per 5-second interval per tag, falls inside it and the count divides cleanly by the resolution. An inclusive bound would pull in the next day's midnight sample and make the expected count harder to state.

Does the Average retrieval mode change how many rows come back?

No, not for a tag that covers the whole window. The resolution decides how many intervals the window is cut into, and the mode decides what each returned value represents, with Average condensing each interval's stored samples into one averaged value. Change the mode and the meaning of each point changes; keep it fixed and the row count stays predictable.

Keep reading

  • How-to

    Inhibit historian logging of one tag with a Boolean gate

    There is no per-tag inhibit command. $HistoricalLogging is global: writing 0 to it stops InTouch historical logging for the whole application. Instead, log a memory Real tag that copies the process tag only while a Boolean permits, keep the live tag updating for display and alarms, and force one catch-up copy when the inhibit clears.

    Edge computing and IIoT

  • Troubleshooting

    Query tag history from a remote tag provider

    Yes: Tag Historian is one module with two jobs — storage and retrieval — so the gateway where system.tag.queryTagHistory runs must license it too. Install and license the module on the querying gateway; from 8.1 a read-only license covers a gateway that only consumes history. Prove the fix by matching row counts between the two gateways.

    Edge computing and IIoT

  • Troubleshooting

    Why Edge historian gaps look like held values centrally

    The single _exempt_ row in sqlth_sce and the empty sqlth_scinfo are designed behavior: the Edge Historian neither tracks nor validates scan classes, locally or over sync, so an outage queries as a held last value on the central gateway. Add a PLC-sourced heartbeat tag, detect holes in its rows as outage windows, and subtract them from runtime totals - a weekend outage otherwise overstated runtime by 16 hours.

    Edge computing and IIoT

Why redundant historians recover from Sender disk buffering