I’m running some queries on tracker analytics table, and noticed that “count(distinct tei)” and “count(distinct psi)” return slightly different values on a sql query.
Using “psi” gives me bigger values, but I’ve seen people using “tei” on queries.
So, I would like to understand why do both get me different results? On which situations one would be more appropriate to use?
I believe that psi stands for program stage instance, and tei stands for tracked entity instance.
The queries are to fetch events from a tracker program.
Hi @joao.machiana, Depending on what you want to do, you could use either; tei is the entity you are tracking; it could be a person or item, like in the malaria program; tei is the person accessing the malaria program. On the other hand, psi counts the number of times the same program stage is repeated either for the same tei or just for the program stage across different teis. Each time a program stage is repeated, it’s assigned a new psi, but the tei will remain the same across the repeats, so if you are to distinct on both, you will have 1 tei apreaing in more different psi(s) depending on how many times the program stage was repeated for that same tei.