Pre-Submission Checklist

Type Of Change

Checklist:

Description

Function ps_watchers_db_timer_clean() inside src/modules/presence/subscribe.c is called repeatedly on my setup.
Each time is called it performs a delete inside table watchers comparing columns inserted_time and status which are not indexed:

MariaDB [kamailio]> explain delete from `watchers` where `inserted_time`<1656252889 AND `status`=2;
+------+-------------+----------+------+---------------+------+---------+------+------+-------------+
| id   | select_type | table    | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+----------+------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | watchers | ALL  | NULL          | NULL | NULL    | NULL | 1    | Using where |
+------+-------------+----------+------+---------------+------+---------+------+------+-------------+

Can we consider adding an index improving performance a bit?

MariaDB [kamailio]> CREATE INDEX inserted_time_status_idx ON watchers (`inserted_time`, `status`);
Query OK, 0 rows affected (0.015 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [kamailio]> explain delete from `watchers` where `inserted_time`<1656252889 AND `status`=2;
+------+-------------+----------+-------+--------------------------+--------------------------+---------+------+------+-------------+
| id   | select_type | table    | type  | possible_keys            | key                      | key_len | ref  | rows | Extra       |
+------+-------------+----------+-------+--------------------------+--------------------------+---------+------+------+-------------+
|    1 | SIMPLE      | watchers | range | inserted_time_status_idx | inserted_time_status_idx | 4       | NULL | 1    | Using where |
+------+-------------+----------+-------+--------------------------+--------------------------+---------+------+------+-------------+
1 row in set (0.001 sec)

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/3182

Commit Summary

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/pull/3182@github.com>