<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[syslog table Index]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I noticed that when I do a search in Syslog, it appears reasonably fast.<br />
But if I select a device, right-click and select Syslog it can take forever to load anything.</p>
<p dir="auto">So I had a look at the database and found the table only has an index on the msg_timestamp (and msg_id) column, but not the source_object_id one.<br />
Of course I could add one manually (and did for now, which sped things up significantly), but that might cause issues with future NetXMS database upgrades down the track?</p>
<p dir="auto">Cheers</p>
]]></description><link>https://forum.netxms.org/topic/4886/syslog-table-index</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 11:12:10 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4886.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Jan 2017 21:15:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to syslog table Index on Wed, 01 Feb 2017 12:05:49 GMT]]></title><description><![CDATA[<p dir="auto">Yes, I also long been noticed and reported to the developers.</p>
<pre><code>Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument
# Time: 161205 12:13:27
# User@Host: netxms[netxms] @  [127.0.0.1]
# Query_time: 101.202518  Lock_time: 0.000060 Rows_sent: 30  Rows_examined: 6502043
use netxms;
SET timestamp=1480929207;
SELECT msg_timestamp,source_object_id,facility,severity,hostname,msg_tag,msg_text FROM syslog WHERE msg_id&lt;=11313990 AND (source_object_id = 38025) ORDER BY msg_timestamp DESC LIMIT 1000;

mysql&gt; EXPLAIN SELECT msg_timestamp,source_object_id,facility,severity,hostname,msg_tag,msg_text FROM syslog WHERE msg_id&lt;=11313990 AND (source_object_id = 38025) ORDER BY msg_timestamp DESC LIMIT 1000;
+----+-------------+--------+-------+---------------+--------------------------+---------+------+------+-------------+
| id | select_type | table  | type  | possible_keys | key                      | key_len | ref  | rows | Extra       |
+----+-------------+--------+-------+---------------+--------------------------+---------+------+------+-------------+
|  1 | SIMPLE      | syslog | index | PRIMARY       | idx_syslog_msg_timestamp | 4       | NULL | 2000 | Using where |
+----+-------------+--------+-------+---------------+--------------------------+---------+------+------+-------------+
1 row in set (0.00 sec)

Uptime:                 87 days 15 hours 26 min 22 sec

Threads: 14  Questions: 3302913014  Slow queries: 504  Opens: 5677  Flush tables: 1  Open tables: 4130  Queries per second avg: 436.178

select count(*) from syslog;
+----------+
| count(*) |
+----------+
|  6502281 |
+----------+
1 row in set (2.01 sec)

mysql&gt; set profiling=1;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; show profile for query 1;
+--------------------------------+-----------+
| Status                         | Duration  |
+--------------------------------+-----------+
| starting                       |  0.000085 |
| Waiting for query cache lock   |  0.000007 |
| checking query cache for query |  0.000074 |
| checking permissions           |  0.000010 |
| Opening tables                 |  0.000029 |
| System lock                    |  0.000012 |
| Waiting for query cache lock   |  0.000034 |
| init                           |  0.000035 |
| optimizing                     |  0.000019 |
| statistics                     |  0.000103 |
| preparing                      |  0.000047 |
| executing                      |  0.000008 |
| Sorting result                 |  0.000012 |
| Sending data                   | 19.243185 |
| end                            |  0.000030 |
| query end                      |  0.000012 |
| closing tables                 |  0.000011 |
| freeing items                  |  0.000024 |
| logging slow query             |  0.000006 |
| logging slow query             |  0.000097 |
| cleaning up                    |  0.000009 |
+--------------------------------+-----------+
21 rows in set (0.00 sec)

EXPLAIN SELECT msg_timestamp,source_object_id,facility,severity,hostname,msg_tag,msg_text FROM syslog WHERE msg_id&lt;=9880640 AND (source_object_id = 29124) ORDER BY msg_timestamp DESC LIMIT 1000;

*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: syslog
         type: index
possible_keys: PRIMARY
          key: idx_syslog_msg_timestamp
      key_len: 4
          ref: NULL
         rows: 2000
        Extra: Using where
1 row in set (0.00 sec)
</code></pre>
<pre><code>show create table syslog;
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                                                                                                                                                                                                                                                       |
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| syslog | CREATE TABLE `syslog` (
  `msg_id` bigint(20) NOT NULL,
  `msg_timestamp` int(11) NOT NULL,
  `facility` int(11) NOT NULL,
  `severity` int(11) NOT NULL,
  `source_object_id` int(11) NOT NULL,
  `hostname` varchar(127) DEFAULT NULL,
  `msg_tag` varchar(32) DEFAULT NULL,
  `msg_text` text,
  PRIMARY KEY (`msg_id`),
  KEY `idx_syslog_msg_timestamp` (`msg_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql&gt; SELECT msg_timestamp,source_object_id,facility,severity,hostname,msg_tag,msg_text FROM syslog WHERE msg_id&lt;=15375265 AND (source_object_id = 11102) ORDER BY msg_timestamp DESC LIMIT 1000;

1000 rows in set (23.48 sec)

CREATE INDEX idx_syslog_source ON syslog(source_object_id);
Query OK, 0 rows affected (43.65 sec)
Records: 0  Duplicates: 0  Warnings: 0


mysql&gt; SELECT msg_timestamp,source_object_id,facility,severity,hostname,msg_tag,msg_text FROM syslog WHERE msg_id&lt;=15375265 AND (source_object_id = 11102) ORDER BY msg_timestamp DESC LIMIT 1000;

1000 rows in set (0.11 sec)
show index from syslog\G
 1. row
        Table: syslog
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: msg_id
    Collation: A
  Cardinality: 7444594
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
 2. row
        Table: syslog
   Non_unique: 1
     Key_name: idx_syslog_msg_timestamp
 Seq_in_index: 1
  Column_name: msg_timestamp
    Collation: A
  Cardinality: 7444594
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
 3. row
        Table: syslog
   Non_unique: 1
     Key_name: idx_syslog_source
 Seq_in_index: 1
  Column_name: source_object_id
    Collation: A
  Cardinality: 200
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
3 rows in set (0.00 sec)
</code></pre>
]]></description><link>https://forum.netxms.org/post/21771</link><guid isPermaLink="true">https://forum.netxms.org/post/21771</guid><dc:creator><![CDATA[hsvt]]></dc:creator><pubDate>Wed, 01 Feb 2017 12:05:49 GMT</pubDate></item><item><title><![CDATA[Reply to syslog table Index on Tue, 31 Jan 2017 21:41:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I've added to new indexes in 2.1-M3:</p>
<p dir="auto">CREATE INDEX idx_syslog_source ON syslog(source_object_id);<br />
CREATE INDEX idx_snmp_trap_log_oid ON snmp_trap_log(object_id);</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/21769</link><guid isPermaLink="true">https://forum.netxms.org/post/21769</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 31 Jan 2017 21:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to syslog table Index on Mon, 23 Jan 2017 10:41:44 GMT]]></title><description><![CDATA[<p dir="auto">Very good point, I can support that.<br />
We have a few millions of records in the syslog table (PostgreSQL), syslog per node is very slow. Additional indexes could be a good help. Maybe also other performance improvments.</p>
<p dir="auto">Dani</p>
]]></description><link>https://forum.netxms.org/post/21717</link><guid isPermaLink="true">https://forum.netxms.org/post/21717</guid><dc:creator><![CDATA[user54119]]></dc:creator><pubDate>Mon, 23 Jan 2017 10:41:44 GMT</pubDate></item></channel></rss>