# Historian is not returning all raw data

**URL:** <https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950>\
**Category:** General Discussion\
**Tags:** ignition81\
**Created:** [February 19, 2024, 4:13pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950 "2024-02-19T16:13:52Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 4:13pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/1 "2024-02-19T16:13:52Z")

</div>

I am trying to return the raw data from the historian and plot it on a chart. I am not getting all of the data points that exist in the table. I also tried System.Tag.QueryTagHistory and got the same results. What would cause the historian to omit data?

Ignition 8.1.28

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 19, 2024, 4:31pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/2 "2024-02-19T16:31:20Z")

</div>

Show your code. But some requirements to cleanly get historian data "As Stored" via [system.tag.queryTagHistory()](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-queryTagHistory):

- Use `returnSize = -1`

- Omit `aggregationMode`

- Use `returnFormat = 'Tall'`

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/3 "2024-02-19T19:04:08Z")

</div>

Phil - Thanks for the response. I didn't save my earlier code attempts, but here is a retry:

```auto
Tags = ['melting/furnace5/fulltiltcycletime']
EndDate = system.date.now()
StartDate = system.date.addDays(EndDate,-14)
print StartDate

ds = system.tag.queryTagHistory(paths=Tags, startDate=StartDate, endDate=EndDate, returnSize=-1,returnFormat='Tall')
print system.dataset.toCSV(ds)

```

Results:

**Mon Feb 05 14:01:55 EST 2024**  
**"path","value","quality","timestamp"**

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 19, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/4 "2024-02-19T19:08:19Z")

</div>

Hi, d. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). It's especially important for Python / Jython.

All your results are showing up as quotations of quotations of quotations (with nothing actually quoted) so you've got something wrong in your post. (Quotation markdown syntax is `>`.) Can you edit your previous post (pencil icon) and fix it? Thanks.

Use the Preview pane to check your posts before posting.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 19, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/5 "2024-02-19T19:13:36Z")

</div>

How are you determining there is missing data, solely based on what you see in a chart or table? If so, data can interpolated, so what you see in a table or chart might not be what is actually stored in the historian database.

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 7:16pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/6 "2024-02-19T19:16:20Z")

</div>

T-  
Thanks for the info.

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 7:17pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/7 "2024-02-19T19:17:39Z")

</div>

I am directly querying the SQL tables. I should be getting 80+ records for that tagpath.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 19, 2024, 7:18pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/8 "2024-02-19T19:18:43Z")

</div>

May I ask how you are determining you should have 80+ records?

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 7:22pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/9 "2024-02-19T19:22:27Z")

</div>

I run this query to get the TagIDs:

```auto
select * from sqlth_te
where tagpath = 'melting/furnace5/fulltiltcycletime'

```

It returns two entries: 29448, 29474

Then I run this query to get the data.

```auto
select *, dateadd(second,t_stamp/1000,'1970-01-01')
from sqlt_data_3_2024_02
where tagid in (29448, 29474)
order by t_stamp

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 19, 2024, 7:25pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/10 "2024-02-19T19:25:16Z")

</div>

> [@dtompkins](#):
>
> `Tags = ['melting/furnace5/fulltiltcycletime']`

Pretty sure you need the tag provider there.

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 7:31pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/11 "2024-02-19T19:31:14Z")

</div>

Good Catch. I guess I am used to SQL queries. I modified my code to include the provider and now I get 2 out of 80+ expected records

```auto

Tags = ['[OMA]melting/furnace5/fulltiltcycletime']
EndDate = system.date.now()
StartDate = system.date.addDays(EndDate,-14)
print StartDate

ds = system.tag.queryTagHistory(paths=Tags, startDate=StartDate, endDate=EndDate, returnSize=-1,returnFormat='Tall')
print system.dataset.toCSV(ds)

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 19, 2024, 8:06pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/12 "2024-02-19T20:06:31Z")

</div>

> [@dtompkins](#):
>
> It returns two entries: 29448, 29474

I thought historian only used a single ID? For both IDs, is the retired column column null?

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [February 19, 2024, 8:11pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/13 "2024-02-19T20:11:30Z")

</div>

Retired is null for both TagIDs

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 19, 2024, 8:26pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/14 "2024-02-19T20:26:03Z")

</div>

I didn't think historian could use multiple IDs like that, perhaps someone else with more knowledge can verify.

---

<div class="post-metadata">

**Author:** ![dtompkins](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dtompkins](https://forum.inductiveautomation.com/u/dtompkins)\
**Post date:** [March 5, 2024, 1:28pm UTC](https://forum.inductiveautomation.com/t/historian-is-not-returning-all-raw-data/85950/15 "2024-03-05T13:28:21Z")

</div>

We did a reboot at patch time and this seemed to fix the issue. Still don't know the root cause.
