# Total Views Error

**URL:** https://meta.discourse.org/t/total-views-error/119018
**Category:** Support
**Created:** [May 29, 2019, 5:46pm UTC](https://meta.discourse.org/t/total-views-error/119018 "2019-05-29T17:46:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ben.gerber](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@ben.gerber](https://meta.discourse.org/u/ben.gerber)
#### Post date: [May 29, 2019, 5:46pm UTC](https://meta.discourse.org/t/total-views-error/119018/1 "2019-05-29T17:46:42Z")

</div>

The total views reported on the site UI is different than what’s showing in Discourse DB’s topic\_views table(see below for context).

topic link(currently at 9.1k views): [https://talk.fabfitfun.com/t/we-need-your-help-to-prepare-for-summer-edit-19/1170607](https://talk.fabfitfun.com/t/we-need-your-help-to-prepare-for-summer-edit-19/1170607)

query(returning 5.7k views):  
select topic\_id, count(\*) total\_views  
from public.topic\_views  
where topic\_id=1170607  
group by topic\_id

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [May 30, 2019, 5:08pm UTC](https://meta.discourse.org/t/total-views-error/119018/3 "2019-05-30T17:08:00Z")

</div>

> [@ben.gerber](#):
>
> The total views reported on the site UI is different than what’s showing in Discourse DB’s topic\_views table

The topic view data that is displayed in the UI comes from the `views` column of the `topics` table. The `views` column is incremented once per `user_id` or `ip_address` per `topic_id` every 8 hours. The 8 hour period can be changed by overriding the default value of the `topic_view_duration_hours` site setting.

The `topic_views` table only gets a single entry per `topic_id` per `user_id` or `ip_address`. If a user views a topic multiple times, there will only be a single entry for them for the topic in the `topic_views` table. The data from this table is used internally by Discourse to check if a user has met the trust level 3 requirements for topics entered.

You can test this yourself by running the following query with a `:topic_id` from your site:

```sql
select
COUNT(user_id) AS views_per_user
FROM topic_views
WHERE topic_id = :topic_id
GROUP BY user_id
ORDER BY views_per_user DESC

```

You’ll see that `views_per_user` is always 1. This means that you can expect `topics.views` to return a higher value than the sum of `topic_views` for a particular topic ID.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 22, 2022, 7:28am UTC](https://meta.discourse.org/t/total-views-error/119018/5 "2022-11-22T07:28:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
