# What is the best way to query data?

**URL:** <https://forum.inductiveautomation.com/t/what-is-the-best-way-to-query-data/94195>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 5, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/what-is-the-best-way-to-query-data/94195 "2024-08-05T21:31:48Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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:** [August 8, 2024, 12:16pm UTC](https://forum.inductiveautomation.com/t/what-is-the-best-way-to-query-data/94195/13 "2024-08-08T12:16:37Z")

</div>

> [@Pat\_Cunningham](#):
>
> I think I am going to stay with what I have and avoid tag query's and named queries because I can't really see a good reason to use them and doing everything in script seems cleaner.

There are good reasons to use them.

1. They keep your queries organized in a single place and callable from anywhere in the project.
2. Make reusing the same query simpler.
3. Can be cached.
4. Can be used in bindings.

Here is some more advise about when you should and should not use a Named Query

> [@runprepQuery or runNamedQuery - Best Practice](https://forum.inductiveautomation.com/t/runprepquery-or-runnamedquery-best-practice/85792/2):
>
> With the exception of some special cases (ahmmm QueryString parameters). You should almost always default to Named Queries. Performance wise, I doubt there is anything more than negligible gains or losses between the two functions in a scripting environment. They both use the same JDBC driver, so the same queries will basically run exactly the same. Although, I will admit that I don't know if Named Query caching applies to the scripting function or just bindings, so that could make a differe…

---

_[View the full topic](https://forum.inductiveautomation.com/t/what-is-the-best-way-to-query-data/94195)._
