# Can we delete entries from the sessions table?

**URL:** <https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611>\
**Category:** Open Discussions\
**Created:** [February 6, 2023, 6:44pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611 "2023-02-06T18:44:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 6, 2023, 6:44pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/1 "2023-02-06T18:44:39Z")

</div>

Hello all, I noticed when I logged into my MySQL kanboard database recently that my sessions (can’t remember the actual name) was full of entries, around 95,000 or so over the years.

Can I delete them so I got a month’s worth? I can’t seem to find a function or procedure in kanboard for it so I think I would just delete through phpMyAdmin.

Anybody know of any side effects it may cause?

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 8:47am UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/2 "2023-02-07T08:47:24Z")

</div>

I don’t see any danger in deleting, at least where the ‘expire\_at’ is over.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 8:53am UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/3 "2023-02-07T08:53:48Z")

</div>

How can I read/convert that? The date is `int(11)` so it’s just numbers but I can’t find a way to convert it

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 9:31am UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/4 "2023-02-07T09:31:18Z")

</div>

Try this:

Copy the result of

```sql
SELECT MAX(expire_at) FROM sessions

```

to the clipboard. Then use that value for a SELECT to check **(!)**, finally for the DELETE.

```sql
DELETE FROM sessions WHERE expire_at < $your_max_value

```

This removes all record but the newest one.

HTH  
abu

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 11:54am UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/5 "2023-02-07T11:54:59Z")

</div>

If this is too hard for you, you have to calculate an appropriate value. The expire\_at is a UNIX timestamp, aka seconds since Jan 01 1970. (UTC).

Example: To keep just some days back from the newest:

```sql
DELETE FROM sessions WHERE expire_at < ($your_newest_value - $number_of_days * 24 * 3600)

```

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 12:03pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/6 "2023-02-07T12:03:18Z")

</div>

yes this was too hard but I am slowly reading up on the mysql side. After seeing my sessions table having 40mb and 95k entries, I think it needs a clean. Other tables will also need some sort of looking into to keep the database a minimum size.

I will create a neww plugin for this, so that users can click a button to clean entries from the table. starting with sessions. Both your entries will be good options.

You’re more than welcome to collab on the repo, let me know, I will add you.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 12:21pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/7 "2023-02-07T12:21:54Z")

</div>

For me, this brings up the question, why such a table cleanup isn’t done by the nightly cronjob. Removing expired stuff from both, file system and database, is a typical maintenance job.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 12:23pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/8 "2023-02-07T12:23:34Z")

</div>

I dont know, my cron works daily, my actions work, notifications etc… but the table isnt touched… I dont know what cronjob checks for so I thought its by design that the table is so big.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 12:25pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/9 "2023-02-07T12:25:18Z")

</div>

> [@aljawaid](#):
>
> I dont know what cronjob checks for so

Obviously, there isn’t one, but should.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 12:33pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/10 "2023-02-07T12:33:23Z")

</div>

ok great, another flaw of Kanboard… so I will need to create a plugin to bring my database size down.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 12:35pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/11 "2023-02-07T12:35:17Z")

</div>

It was just a remark from my side, not a call for a plugin.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 12:37pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/12 "2023-02-07T12:37:52Z")

</div>

I know, Im just trying to understand whether the database sessions table size is my local issue or a kanboard issue. If its a kanboard issue (no database cleaning via cronjobs by design/oversight) then I need to create a plugin.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [February 7, 2023, 12:54pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/13 "2023-02-07T12:54:26Z")

</div>

Out of curiosity: how large is this instance? Users? How old?  
My session table has just above 100 items, but is living for years. And I never purged.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [February 7, 2023, 12:57pm UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/14 "2023-02-07T12:57:29Z")

</div>

haha my plugin dashboard can answer your question easily (excellent)

 ![image](https://global.discourse-cdn.com/free1/uploads/kanboard1/original/2X/0/09b33a57bc07eb298f3796fb432d2b607fda4fc3.jpeg)

But the database has been used since 2015 with all this data. The date showing in the screenshot was a manual migration when I couldnt upgrade kanboard.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [August 23, 2023, 9:11am UTC](https://kanboard.discourse.group/t/can-we-delete-entries-from-the-sessions-table/2611/15 "2023-08-23T09:11:55Z")

</div>

This can be completed through a cleaning job in the ContentCleaner plugin

> [@New Plugin: ContentCleaner](https://kanboard.discourse.group/t/new-plugin-contentcleaner/2885):
>
> After a long time in the making and with great efforts, contributions and support from @creecros and @alfred, this plugin has been initially released. ContentCleaner gives you greater control of your database from within Kanboard. Cleaning jobs are split into three sections, Automatic, Application and Plugins. Users will find the Application Cleaning Jobs most useful. For example, Job #2 under Application Cleaning resolves issues reported here: [iCal data with duedate only - #54 by alfredb](https://kanboard.discourse.group/t/ical-data-with-duedate-only/2636/54) The…
