# \[5GB DB\] Slowness on first startup

**URL:** <https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211>\
**Category:** Développement\
**Created:** [April 25, 2022, 9:59am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211 "2022-04-25T09:59:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [April 25, 2022, 9:59am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/1 "2022-04-25T09:59:39Z")

</div>

Hello everyone, hello @pierre-gilles,

I’m talking about it on the forum before defining together what you want to see on GitHub 😉  
I’ve been feeling this for a while, but I was able to confirm it now by recording my screen.

**Starting Gladys**  
If the Gladys container is stopped and then started again (after an update for example), the first loading of the graphs takes a lot of time.  
This is certainly partly due to the size of the DB 4.5Go! But not only, since you explained that you only take a very small part of the data to speed up the display.

**Demo video (1m30)**  
Note:

1. The Gladys page is open at the beginning, but do not take it into account
2. I (re) launch Gladys, then I refresh the gladys web page
3. This is where we see the slowness and the high use of the «&nbsp;disk&nbsp;» (SD card at my place)

![](https://gladys-assistant-community.b-cdn.net/uploads/default/optimized/2X/d/d06eb2877aad7e7a0410e810b65d78e479fc0bd8_2_690x388.jpeg)https://www.youtube.com/embed/kjGZmXzDO2k?feature=oembed&wmode=opaque

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [April 26, 2022, 5:05pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/2 "2022-04-26T17:05:18Z")

</div>

Interesting @lmilcent, thanks for the feedback with the video 🙂

First, I see that all your graphs are «&nbsp;last hours&nbsp;» displays, and that’s LIVE data (not aggregated), so it’s possible that there are thousands of lines/hundreds of thousands depending on whether your sensors are verbose or not.

Could you:

- Export your DB
- Open it on your computer (with a tool like [TablePlus](https://tableplus.com/))
- Then, try to filter your table `t_device_feature_state` to see how many lines there are per sensor and per hour, the idea is to understand the volume of data we’re talking about.

Then, we’ll see if it’s a «&nbsp;normal&nbsp;» problem (in the sense that we just need to see how to reduce your data flow if it’s too large), or if on the Gladys side there are DB optimizations to look for 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [April 26, 2022, 9:56pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/3 "2022-04-26T21:56:02Z")

</div>

Running [your last query](https://community.gladysassistant.com/t/help-probleme-avec-lagregation/6630/56?u=lmilcent) to check what’s wrong.

As before, the electrical outlets have the most events:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/1dd94d7bdd7121d6c50e1a71c7787fc7c89895aa.png)

However, I wonder what the value at the very top is:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/0/07d64cd073532708adfaef7681ac40af594ad79e.png)

And for information, the aggregation seems very very very verbose for me (`1-300 of ~8,510,037`), possibly due to the history (the NaN bug itself):

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b72aa99e2e96f5a47ca82cd48a0de85308dfc8dd.png)

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [April 27, 2022, 8:14am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/4 "2022-04-27T08:14:51Z")

</div>

> [@lmilcent](#):
>
> However, I wonder what the value at the very top is:

It looks like a date!!

> [@lmilcent](#):
>
> And for info, the aggregation seems very very very verbose for me (`1-300 of ~8,510,037`), maybe due to the history (the NaN bug itself):

It’s been a long time since I suggested adding an option for each feature to specify whether you want to record all values or only state changes. And with that, update only the last\_value of the device\_feature table, which would allow you to have the date of the last value received to then be able to set an alert if no data is received for x seconds/minutes/etc.  
If you select «&nbsp;Record only state changes&nbsp;» when a state change occurs, you send the old value before to clearly specify on the graphs that you remained at the same value for a certain period of time.

For info, this is what I did on the Netatmo integration by @damalgos and it works very well. No unnecessary values stored.

In the meantime, it’s a shame, but you can always go through Node-red first to sort the values to be recorded or not?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [April 27, 2022, 4:33pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/5 "2022-04-27T16:33:30Z")

</div>

> [@lmilcent](#):
>
> As before, it’s the power outlets that have the most events:

Ah, aren’t these outlets part of the devices that are way too verbose? I think some Zigbee devices send a value every 15-20 seconds even without a state change, which could explain why it’s so full when I imagine you haven’t turned your outlet on 375,000 times 😛

Feel free to do some SQL cleaning on your DB while waiting for a feature in Gladys that allows you to do it in the UI ^^

> [@lmilcent](#):
>
> And for info, aggregation seems very very very verbose for me (`1-300 of ~8,510,037`), maybe due to the history (the NaN bug exactly):

Oho, interesting, I didn’t think there were NaN values in the aggregated data too! That’s not normal!

I’ll add a clean in the next Gladys update, in the meantime, same as last time, you can clean these aggregated data that are clearly useless.

> [@Terdious](#):
>
> It’s been a long time since I submitted the idea of having an option for each feature to say whether we want to record all values or only state changes.

That’s true, I remember! Is there a feature request for that?

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [April 27, 2022, 7:58pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/6 "2022-04-27T19:58:46Z")

</div>

> [@pierre-gilles](#):
>
> > [@Terdious](#):
> >
> > It’s been a long time since I submitted the idea of adding an option for each feature to indicate whether we want to record all values or only state changes.
> 
> That’s right, I remember! Is there a feature request for that?

Mmmh I thought so but I’m not sure!!^^ I’ll double-check!!

**Edit** :  
@pierre-gilles, I found it: [Case à cochée "Ne pas enregistrer les nouvelles valeurs identiques" + Choix de durée de backup indépendant pour chaque Device Features - #2 par pierre-gilles](https://community.gladysassistant.com/t/case-a-cochee-ne-pas-enregistrer-les-nouvelles-valeurs-identiques-choix-de-duree-de-backup-independant-pour-chaque-device-features/5963/2)

I’d be happy to take care of it as soon as possible (I did it for the Netatmo service that runs at home and it works perfectly). However, you would need to validate the operating principle so as not to start something and have to redo everything.

- **Front-end** :

- **Server-side** :

```json
{
  "name": "[feature id]:only_keep_value_changes",
  "value": true
}

```

- if the value of this parameter is true and the new value is the same as the previous one, we go through a new file server/lib/device/device.saveLastStateChanged.js to save in the t\_device\_feature table the `saveLastStateChanged` as you asked me at the time of the Netatmo dev:

```javascript
const db = require('../../models');
const logger = require('../../utils/logger');
const { EVENTS, WEBSOCKET_MESSAGE_TYPES } = require('../../utils/constants');

/**
 * @description Save new device feature state in DB.
 * @param {Object} deviceFeature - A DeviceFeature object.
 * @example
 * saveLastValueChanged({
 * id: 'fc235c88-b10d-4706-8b59-fef92a7119b2',
 * selector: 'my-light'
 * });
 */
async function saveLastStateChanged(deviceFeature) {
  // logger.debug(`device.saveLastStateChanged of deviceFeature ${deviceFeature.selector}`);
  const now = new Date();
  // save local state in RAM
  this.stateManager.setState('deviceFeature', deviceFeature.selector, {
    last_value_changed: now,
  });
  await db.sequelize.transaction(async (t) => {
    // update deviceFeature lastValue in DB
    await db.DeviceFeature.update(
      {
        last_value_changed: now,
      },
      {
        where: {
          id: deviceFeature.id,
        },
      },
      {
        transaction: t,
      },
    );
  });

  // send websocket event
  this.eventManager.emit(EVENTS.WEBSOCKET.SEND_ALL, {
    type: WEBSOCKET_MESSAGE_TYPES.DEVICE.NEW_STATE_NO_CHANGED,
    payload: {
      device_feature_selector: deviceFeature.selector,
      last_value_changed: now,
    },
  });
}

module.exports = {
  saveLastStateChanged,
};

```

- When the value changes again, we go back through the function of the file server/lib/device/device.saveState.js that we must modify to re-record, before the new value, the old value already in the database, to have an adjusted curve:

```javascript
const db = require('../../models');
const logger = require('../../utils/logger');
const { EVENTS, WEBSOCKET_MESSAGE_TYPES } = require('../../utils/constants');
const { BadParameters } = require('../../utils/coreErrors');

const DEFAULT_OPTIONS = {
  skip: 0,
  order_dir: 'DESC',
  order_by: 'created_at',
}

/**
 * @description Save new device feature state in DB.
 * @param {Object} deviceFeature - A DeviceFeature object.
 * @param {number} newValue - The new value of the deviceFeature to save.
 * @example
 * saveState({
 * id: 'fc235c88-b10d-4706-8b59-fef92a7119b2',
 * selector: 'my-light'
 * }, 12);
 */
async function saveState(deviceFeature, newValue) {
  if (Number.isNaN(newValue)) {
    throw new BadParameters(`device.saveState of NaN value on ${deviceFeature.selector}`);
  }
  const optionsWithDefault = Object.assign({}, DEFAULT_OPTIONS);

  // logger.debug(`device.saveState of deviceFeature ${deviceFeature.selector}`);
  const now = new Date();
  const previousDeviceFeature = this.stateManager.get('deviceFeature', deviceFeature.selector);
  const previousDeviceFeatureValue = previousDeviceFeature ? previousDeviceFeature.last_value : null;

  const previousDeviceFeatureLastValueChanged = previousDeviceFeature ? previousDeviceFeature.last_value_changed : null;

  const deviceFeaturesState = await db.DeviceFeatureState.findOne({
    attributes: ['device_feature_id', 'value', 'created_at'],
    order: [[optionsWithDefault.order_by, optionsWithDefault.order_dir]],
    where: {
      device_feature_id: deviceFeature.id,
    },
  });
  const previousDeviceFeatureStateLastValueChanged = deviceFeaturesState ? deviceFeaturesState.created_at : 0;

  // save local state in RAM
  this.stateManager.setState('deviceFeature', deviceFeature.selector, {
    last_value: newValue,
    last_value_changed: now,
  });
  // update deviceFeature lastValue in DB
  await db.DeviceFeature.update(
    {
      last_value: newValue,
      last_value_changed: now,
    },
    {
      where: {
        id: deviceFeature.id,
      },
    },
  );
  // if the deviceFeature should keep history, we save a new deviceFeatureState
  if (deviceFeature.keep_history) {
    // if the previous created deviceFeatureState is different of deviceFeature
    // last value changed, we save a new deviceFeatureState of old state
    if (previousDeviceFeatureLastValueChanged - previousDeviceFeatureStateLastValueChanged > 0) {
      await db.DeviceFeatureState.create({
        device_feature_id: deviceFeature.id,
        value: previousDeviceFeatureValue,
        created_at: previousDeviceFeatureLastValueChanged,
      });
    }
    await db.DeviceFeatureState.create({
      device_feature_id: deviceFeature.id,
      value: newValue,
    });
  }
  // });

  // send websocket event
  this.eventManager.emit(EVENTS.WEBSOCKET.SEND_ALL, {
    type: WEBSOCKET_MESSAGE_TYPES.DEVICE.NEW_STATE,
    payload: {
      device_feature_selector: deviceFeature.selector,
      last_value: newValue,
      last_value_changed: now,
    },
  });

  // check if there is a trigger matching
  this.eventManager.emit(EVENTS.TRIGGERS.CHECK, {
    type: EVENTS.DEVICE.NEW_STATE,
    device_feature: deviceFeature.selector,
    previous_value: previousDeviceFeatureValue,
    last_value: newValue,
    last_value_changed: now,
  });
}

module.exports = {
  saveState,
}

```

For example, if we receive for a consumed power:

```json
{
  value: 1014.7,
  created_at: 2022-04-19 04:20:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 04:30:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 04:40:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 04:50:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 05:00:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 05:10:13.277 +00:00
},
{
  value: 78.0,
  created_at: 2022-04-19 05:20:13.277 +00:00
}

```

We will only find in the DB

```json
{
  value: 1014.7,
  created_at: 2022-04-19 04:20:13.277 +00:00
},
{
  value: 1014.9,
  created_at: 2022-04-19 04:30:13.277 +00:00
},
// here we did not save the identical values
{
  value: 1014.9,
  created_at: 2022-04-19 05:10:13.277 +00:00
},
// After writing the value below, we sent
{
  value: 78.0,
  created_at: 2022-04-19 05:20:13.277 +00:00
}

```

Do you see it differently? In that case, would you roughly have the line to follow?

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [April 28, 2022, 6:07am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/7 "2022-04-28T06:07:57Z")

</div>

For the second point on the history,

- **Front side** :

- **Server side** :

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [April 28, 2022, 6:47am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/8 "2022-04-28T06:47:01Z")

</div>

I’m modifying the db to avoid storing everything in history, for example, the aqara sensors. In my opinion, it’s pointless to historize atmospheric pressure in each room since the values will be identical.

My DB is 2GB.

But it’s true that we’ve already had this discussion somewhere on the forum.

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [April 28, 2022, 7:31am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/9 "2022-04-28T07:31:26Z")

</div>

And finally a PR for the scenes to be able to send an alert in case of non-receipt of a value during a time period on a device.  
Example:  
Trigger: «&nbsp;Every 10 minutes&nbsp;» (Existing)  
Action: «&nbsp;Retrieve the last update date of the (feature(s))&nbsp;» (last\_value\_changed) with selection of one feature per device, for example the battery (To be developed)  
Action: «&nbsp;Continue only if more than 10 minutes&nbsp;» (To be developed - subtraction)  
Action: «&nbsp;Send a message&nbsp;» (with variable(s)) (last\_value\_changed will probably need to be added)

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [April 28, 2022, 7:33am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/10 "2022-04-28T07:33:45Z")

</div>

> [@VonOx](#):
>
> But it’s true that we’ve already had this discussion somewhere on the forum

On my side, I found the feature request, you indeed voted for it as well ^^ But no answer on it. I don’t find any other similar topics …

> [@Terdious](#):
>
> **Edit** :  
> @pierre-gilles, I found it: [Checkbox «&nbsp;Do not save new identical values&nbsp;» + Independent backup duration choice for each Device Features](https://community.gladysassistant.com/t/case-a-cochee-ne-pas-enregistrer-les-nouvelles-valeurs-identiques-choix-de-duree-de-backup-independant-pour-chaque-device-features/5963/2)

If you have time to read the 2 previous posts and give your opinion on the proposal, it will be with pleasure ^^

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [April 28, 2022, 2:23pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/11 "2022-04-28T14:23:30Z")

</div>

Thank you all for your responses. I’ll leave you to it and thank you for working on this 😊

I am on vacation without easy access to my PC or the database, so I will do all that when I get back.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 3, 2022, 4:06pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/12 "2022-05-03T16:06:58Z")

</div>

Hi @lmilcent, a small gift for when you get back from vacation, I made a quick PR to clean the `t_device_feature_state_aggregate` table of NaN values 🙂

> <https://github.com/GladysAssistant/Gladys/pull/1513>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fa…st as possible, make sure to review and check all of these items:
> 
> \- \[\] If your changes affects code, did your write the tests?
> \- \[\] Are tests passing? (\`npm test\` on both front/server)
> \- \[\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[\] If you are adding a new features/services, did you run integration comparator? (\`npm run compare-translations\` on front)
> \- \[\] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to \[the community\](https://community.gladysassistant.com/) for testing before merging.
> \- \[\] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
> \- \[\] If you are adding a new features/services which needs explanation, did you modify the user documentation? See \[the GitHub repo\](https://github.com/GladysAssistant/v4-website) and the \[website\](https://gladysassistant.com).
> \- \[\] Did you add fake requests data for the demo mode (\`front/src/config/demo.js\`) so that the demo website is working without a backend? (if needed) See \[https://demo.gladysassistant.com\](https://demo.gladysassistant.com).
> 
> NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
> 
> \### Description of change
> 
> Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!

It’s not included in the release I’m going to make today, it will go into the next one.

> [@Terdious](#):
>
> If you have the time to read the previous 2 posts and give your opinion on the proposal it would be a pleasure ^^

To start, let’s keep it simple and do it well, I think there’s nothing to do on the server side.

We just need to add in the interface a button «&nbsp;Keep the history of this device’s values&nbsp;»: checked or not.

This boolean will modify the `keep_history` attribute which already exists and already works on the server side. It’s 2 hours of work all in, the time to make the PR, and there’s no specification to write because the functionality already exists 🙂

Adding per-device history complicates the product quite a bit and needs thought (what about aggregation? Which takes precedence: the global setting or the per-device setting?). In short, in my opinion let’s stay focused on the essentials for now.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 3, 2022, 4:54pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/13 "2022-05-03T16:54:38Z")

</div>

A post has been split into a new topic: [Save or Not Save the History of a Specific Feature](https://community.gladysassistant.com/t/sauvegarder-ou-pas-lhistorique-dune-fonctionnalites-precise/7241)

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [May 6, 2022, 2:53pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/14 "2022-05-06T14:53:47Z")

</div>

Great, thanks 🙂  
Nice surprise to come back to after vacation!

> [@pierre-gilles](#):
>
> You just need to add to the interface a button « Keep this device’s value history »: checked or not.

So, no aggregation of values over 24h, since only the last value is kept, _right_ ?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 9, 2022, 8:05am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/15 "2022-05-09T08:05:23Z")

</div>

> [@lmilcent](#):
>
> So, no aggregation of values over 24 hours, since only the last value is kept, _right_ ?

There is no history at all then, only one value is kept, the last one 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [May 9, 2022, 4:49pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/16 "2022-05-09T16:49:59Z")

</div>

> [@VonOx](#):
>
> I’m modifying the DB so as not to record everything

How do you do that?

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [May 9, 2022, 5:31pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/17 "2022-05-09T17:31:37Z")

</div>

I open the DB with DB Browser and edit the keep\_history column in the device\_feature table

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 13, 2022, 4:38pm UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/18 "2022-05-13T16:38:14Z")

</div>

@lmilcent DB fix deployed!

> [@Gladys Assistant v4.8.5 est disponible, avec 2 correctifs!](https://community.gladysassistant.com/t/gladys-assistant-v4-8-5-est-disponible-avec-2-correctifs/7285):
>
> Salut à tous, J’ai déployé cet après midi Gladys Assistant v4.8.5, une mise à jour qui apporte 2 correctifs: Un fix sur l’intégration Zigbee2mqtt ou certains appareils binaires étaient inversés (Porte ouverte/fermée). Fix par @AlexTrovato [#1517](https://github.com/GladysAssistant/Gladys/pull/1517) Une migration de base de donnée pour nettoyer certaines valeurs agrégées de capteurs qui ont été sauvegardés en «&nbsp;NaN&nbsp;» dans la DB dans le passé, et qui remplissent la base de donnée inutilement. @lmilcent c’est pour toi celle là wink [#1513](https://github.com/GladysAssistant/Gladys/pull/1513) Cette …

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [May 14, 2022, 10:58am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/19 "2022-05-14T10:58:30Z")

</div>

I noticed that Gladys worked for a very long time, so I infer that it cleaned the data, although I haven’t checked yet.  
I manually ran a VACUUM which freed up 100 MB.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 14, 2022, 11:10am UTC](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211/20 "2022-05-14T11:10:14Z")

</div>

Great 🙂 We’ll see how it looks at the next save

[Next page](https://community.gladysassistant.com/t/db-de-5go-lenteurs-au-premier-demarrage/7211.md?page=2)
