# Pulire i log dei token di autenticazione utente?

**URL:** <https://meta.discourse.org/t/clean-up-user-auth-token-logs/326397>\
**Category:** Bug\
**Created:** [13 Settembre 2024, 5:30pm UTC](https://meta.discourse.org/t/clean-up-user-auth-token-logs/326397 "2024-09-13T17:30:22Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [13 Settembre 2024, 5:30pm UTC](https://meta.discourse.org/t/clean-up-user-auth-token-logs/326397/1 "2024-09-13T17:30:22Z")

</div>

Abbiamo un forum in cui `user_auth_token_logs` ha 61 milioni di righe (e in crescita).

Ci sono solo 25 mila `user_auth_tokens`.

Delle 61 milioni di righe, 54 milioni di righe si riferiscono a un `user_auth_token` che non esiste più (cioè un problema di integrità del database). E delle 61 milioni di righe, circa 58 milioni hanno più di 2 mesi (cioè apparentemente inutili?)

Domande:

- Potremmo semplicemente ripulire questo senza rischiare ulteriori problemi di integrità?
- Sarebbe un’idea avere un job che ripulisca automaticamente?

```plaintext
db=# select count(*) from user_auth_tokens;
 count
-------
 25648

db=# select count(*) from user_auth_token_logs;
  count
----------
 61415352

db=# select count(*) from user_auth_token_logs where user_auth_token_id not in (select id from user_auth_tokens);
  count
----------
 54558442

db=# select count(*) from user_auth_token_logs where created_at < '2024-07-13';
  count
----------
 58565943

```

---

_[View the full topic](https://meta.discourse.org/t/clean-up-user-auth-token-logs/326397)._
