# Mysterious entries in topic\_users table

**URL:** <https://meta.discourse.org/t/mysterious-entries-in-topic-users-table/44080>\
**Category:** Bug\
**Created:** [May 11, 2016, 8:17pm UTC](https://meta.discourse.org/t/mysterious-entries-in-topic-users-table/44080 "2016-05-11T20:17:39Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)\
**Post date:** [May 12, 2016, 6:52am UTC](https://meta.discourse.org/t/mysterious-entries-in-topic-users-table/44080/10 "2016-05-12T06:52:53Z")

</div>

I’ve been looking at topic\_users a bit lately.

I was confused as to why there would be these two fields

```plaintext
last_read_post_number integer null 
highest_seen_post_number integer null 

```

I mean, if I read it, I saw it, no?

Then I found this in app/models/topic\_user.rb

```plaintext
      # In case anyone seens "highest_seen_post_number" and gets confused, like I do.
      # highest_seen_post_number represents the highest_post_number of the topic when
      # the user visited it. It may be out of alignment with last_read, meaning
      # ... user visited the topic but did not read the posts

```

In other words, if a topic has 100 posts, but I only read the first 50, the two will not be the same.

I just ran

```plaintext
SELECT *
FROM topic_users
WHERE last_read_post_number IS NULL 
OR highest_seen_post_number IS NULL

```

In _all_ results _both_ read and seen were NULL  
and I noticed in _all_ results total\_msecs\_viewed was zero.

In some, it was not the topic id that was used, but the post id

 ![](https://global.discourse-cdn.com/meta/original/3X/f/6/f6727d154903a489839ed6d5e2612df3c7765bdb.png)

My guess, without having looked more closely into the code yet, is that there is a “divide by 0” error happening somewhere.

---

_[View the full topic](https://meta.discourse.org/t/mysterious-entries-in-topic-users-table/44080)._
