# Limit to system.tag.queryTagHistory tag path array?

**URL:** <https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 21, 2023, 9:41pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364 "2023-06-21T21:41:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [June 21, 2023, 9:41pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/1 "2023-06-21T21:41:10Z")

</div>

Is there a limit to the size of the tag path array that can be passed into the **system.tag.queryTagHistory** function? I have a query that seems to work fine up to 2096 tags, as soon as I perform a query for 2097 tags I get strange results (all zeroes for my aggregated data). Here is a snip of the code:

```auto
queryPaths = tagPaths #List of tags in a list, seems to work fine up until the list is >2096
queryAggregation = 'Count'
queryColumnNames = tagPaths #List of tags in a list
queryReturnSize = 1 #Return 1 aggregated value
	
queryResults = system.tag.queryTagHistory(paths = queryPaths , startDate=startDateIn, endDate=endDateIn, returnSize=queryReturnSize, aggregationMode=queryAggregation, columnNames=queryColumnNames)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 21, 2023, 9:44pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/2 "2023-06-21T21:44:15Z")

</div>

There's nothing explicitly encoded, but I could see a variety of ways this could break down.

Where are you calling the function from?

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [June 21, 2023, 9:49pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/3 "2023-06-21T21:49:59Z")

</div>

I was trying to run it with an asynchronously called method (utilizing **system.util.invokeAsynchronous** ) in Perspective.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 21, 2023, 9:57pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/4 "2023-06-21T21:57:53Z")

</div>

Any errors in the gateway logs about exceeding message size limits? In your async thread, can you confirm the list is as long as you expect it to be and has all the paths you expect? If you set tag-related loggers to TRACE, can you see the paths you expect being output? Maybe the `tags.history.query.dataloader` logger, specifically.

---

<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:** [June 22, 2023, 12:46am UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/5 "2023-06-22T00:46:05Z")

</div>

Sounds suspiciously close to the limit on the number of `?` parameters in some JDBC drivers....

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [June 22, 2023, 5:22pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/6 "2023-06-22T17:22:17Z")

</div>

Yeah, it looks like I'm hitting a limit on parameters (2100). Sounds like @pturmel was on the right track. See the top line of the logs below.

For some insight/clarification:

- Where does this limit come from? For example, is it from the driver that the **system.tag.queryTagHistory** function calls automatically?
- Is there a way around it?
- Any other thoughts?

```auto
com.microsoft.sqlserver.jdbc.SQLServerException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)

at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1662)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:615)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:537)

at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 22, 2023, 5:27pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/7 "2023-06-22T17:27:51Z")

</div>

> [@j.israelsen](#):
>
> - Where does this limit come from? For example, is it from the driver that the **system.tag.queryTagHistory** function calls automatically?

The limit comes from the server. [Incorrect parameters list size · Issue #1980 · microsoft/mssql-jdbc · GitHub](https://github.com/microsoft/mssql-jdbc/issues/1980)  
The MSSQL JDBC driver translates the error returned by the server into a useful Java exception.

> [@j.israelsen](#):
>
> - Is there a way around it?

Probably not. Maybe some way to tweak MSSQL, but seems unlikely, from some quick googling.

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [June 22, 2023, 5:34pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/8 "2023-06-22T17:34:44Z")

</div>

Very interesting, I see that this seems to be tied to MSSQL specifically. So I imagine there are other similar limitations on other databases?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 22, 2023, 5:43pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/9 "2023-06-22T17:43:30Z")

</div>

Yes

You could batch the tag list and then use `system.dataset.appendDataset()` to return the complete dataset.

---

<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:** [June 22, 2023, 6:19pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/10 "2023-06-22T18:19:11Z")

</div>

> [@j.israelsen](#):
>
> So I imagine there are other similar limitations on other databases?

IIRC, it's around 4k or so for PostgreSQL.

---

<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:** [January 5, 2024, 7:46pm UTC](https://forum.inductiveautomation.com/t/limit-to-system-tag-querytaghistory-tag-path-array/75364/11 "2024-01-05T19:46:07Z")

</div>

Surprisingly nice alternative for PostgreSQL:

> [@Taking a Dataset and Inserting it to a SQL temp table](https://forum.inductiveautomation.com/t/taking-a-dataset-and-inserting-it-to-a-sql-temp-table/83852/4):
>
> If you were using a competent database (the following is PostgreSQL), you can pass java arrays as arguments, and unnest() them in a FROM clause. For an example, I created a table in my psql forum playground called phrases, to be used in a join. When queried by itself, you get this dataset: "#NAMES" "prefix","suffix" "#TYPES" "str","I" "#ROWS","4" "Hello","1" "Good Bye","2" "Welcome to","3" "Whoa!","4" To go with that, in a custom property named lookups, I created the following unbound datase…
