delete old positions and keep 3 months

josyaguilar6 years ago

hello, im using traccar 3.10 with more then 100 gps and mysql 5.6. system work perfect no problems since 1 year. but i need to delete old positions and keep only the last 3 months. reports are taking to much time to load.

can some one help me with the mysql script or how to do it.

thanks

Anton Tananaev6 years ago

Check deletePositions and deleteEvents SQL scripts in the config file.

josyaguilar6 years ago

DO I NEED TO USE MYSQL WORKBENCH OR ADDING THIS LINE TO THE TRACCAR.XML FILE

<entry key='database.positionsHistoryDays'>90</entry>

CAN YOU TELL ME THE STEP TO DO IT PLEASE. IM USING TRACCAR 3.10. AND 2 YEARS OF DATA IN MYSQL. THANKS

Anton Tananaev6 years ago

Please don't write in all-caps.

josyaguilar6 years ago

do i need to use mysql workbench or adding this line to the traccar.xml file

<entry key='database.positionsHistoryDays'>90</entry>

can you help me with the steps to do it please. im using traccar 3.10 and 2 years of data in mysql. thanks

Anton Tananaev6 years ago

You can use configuration parameter, but the request might timeout because you have a lot of data. I'm also not sure if it's available in version 3.10.

Leif Neland6 years ago

If it does timeout, then the solution is to do it in small steps; start at for instance 600 days, then 550, 500 etc, until you are down at your 90 days.

yomeka3 years ago

<entry key='database.positionsHistoryDays'>90</entry> Is It avalable for the current version ?

Anton Tananaev3 years ago

No, it's not. We have a different recommendation now due to the issue I mentioned above:

https://www.traccar.org/clear-history/

Stewart3 years ago

Is there an equivlient to https://www.traccar.org/clear-history/ if using the H2 database?

Anton Tananaev3 years ago

No, but you should never use H2 for production.

asher3 years ago

Hi Anton,

Within tc_events there is no column name called eventTime.

+---------------+---------------+------+-----+---------+----------------+
| Field         | Type          | Null | Key | Default | Extra          |
+---------------+---------------+------+-----+---------+----------------+
| id            | int           | NO   | PRI | NULL    | auto_increment |
| type          | varchar(128)  | NO   |     | NULL    |                |
| servertime    | timestamp     | NO   |     | NULL    |                |
| deviceid      | int           | YES  | MUL | NULL    |                |
| positionid    | int           | YES  |     | NULL    |                |
| geofenceid    | int           | YES  |     | NULL    |                |
| attributes    | varchar(4000) | YES  |     | NULL    |                |
| maintenanceid | int           | YES  |     | NULL    |                |
+---------------+---------------+------+-----+---------+----------------+
Anton Tananaev3 years ago

It means you are not using the latest release or you haven't upgraded correctly.

Jansarts8 months ago

Why can't h2 be used in production?

Anton Tananaev8 months ago

Because it doesn't scale well, there's no good tooling around it and you also might lose all the data due to corruption. There's just no single good reason to use it.