Skip to main content
Planview Customer Success Center

How can I get only the current state of each artifact from Hub?

Last Updated:    |  Applicable Hub Versions: All

Answer

Hub writes a new row to the database capturing the new state of an artifact each time it detects that an artifact has changed.

If you are only interested in the current state of each artifact, you can create a view on your database table with the following query, which returns the latest row (i.e., last known state) for each artifact:

SELECT * FROM data.artifacts WHERE id IN (SELECT MAX(id) FROM data.artifacts GROUP BY artifact_id)

Where data.artifacts is the name of your table, and artifact_id is the name of the column representing an artifact's ID or Formatted ID (or any other unique field).

Alternatively, if you are only interested in the current state of each artifact, and are concerned with saving space in your database, you can periodically run the following query, which will delete all rows from your table except the latest row for each artifact:

DELETE A FROM data.artifacts A, data.artifacts B WHERE A.artifact_id = B.artifact_id AND B.id > A.id