Skip to main content
Industrial Data Management
PI System Tips

Leveraging PI System's picomp2 Table for Efficient Time-Stamp Retrievals

Learn how to efficiently retrieve the timestamp of the last good value for a large list of tags in the PI System using picomp2 table for optimized data handling.

Roshan Soni

4 min read

Leveraging PI System's picomp2 Table for Efficient Time-Stamp Retrievals

In the world of industrial operations and monitoring, data efficiency is key, especially when dealing with extensive datasets in systems like OSIsoft PI. A common task for PI System users is retrieving the timestamp of the last good value across numerous tags. This task can become complicated when scaling from a handful to potentially thousands of tags. Here's how you can efficiently manage this within PI's ecosystem.

The Conventional Approach and Challenges

A typical SQL query designed to extract the timestamp of the last good value would look something like this:

SELECT tag, MAX("time") as Last_timestamp 
FROM picomp 
WHERE tag IN (SELECT tag FROM pipoint WHERE pointsource ='X' AND tag LIKE 'BIO:%') 
AND status = 0 
GROUP BY tag

This approach works seamlessly for a small number of tags, but as the number grows, users often encounter performance issues or errors related to event collection limits—like the one described by error code [-11091].

Optimizing with picomp2

A more sophisticated solution is to switch from picomp to the picomp2 table. The picomp2 table is optimized for such queries, particularly due to its ability to utilize the TOP clause, optimizing data retrieval and filtering operations on the server side.

Here's the optimized query syntax:

SELECT TOP 1 tag, time, value 
FROM picomp2 
WHERE tag IN (SELECT tag FROM pipoint WHERE pointsource ='X' AND tag LIKE 'BIO:%') 
AND status = 0 
ORDER BY tag, time DESC

Why picomp2?

The crucial difference with picomp2 is its efficiency in handling ordered data retrieval. By using the TOP 1 clause, picomp2 quickly narrows down the dataset to the most relevant entries (i.e., the last good value per tag) without overwhelming the network transfer or client-side processing.

This adjustment not only resolves the issue of event collection limits but also significantly enhances query performance—making it ideal for large batches of data.

Implementing the Solution

  • Review Your Tag Selection: Ensure your tag list sharpens focus on necessary datasets;

  • Replace MAX with TOP 1: Utilize server-side efficiencies without excess data backhaul;

  • Test and Validate: Always validate your results against your operational data requirements.

By embracing these tweaks, you can maintain operational insight effortlessly, even amidst the vast data landscapes common in modern production environments. Leverage OSIsoft PI's powerful infrastructure with a strategic approach and maximize your system's potential.

Conclusion

Data management in large-scale systems requires strategic choices in query design and data retrieval methodologies. By optimizing queries with the right tables and clauses, you can overcome typical performance hurdles and maintain robust, scalable operations. Transition your queries to picomp2 and experience enhancements in both performance and reliability, keeping your systems agile and responsive.


Tags

#OSIsoft PI
#PI System
#SQL Queries
#Event Collection
#Data Optimization

About Roshan Soni

Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.

Sign in to comment

Join the conversation by signing in to your account.

Comments (0)

No comments yet

Be the first to share your thoughts on this article.

Related Articles

Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead

A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.

Roshan Soni

Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB

Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.

Roshan Soni

Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?

Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.

Roshan Soni