Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-1422

Help mysql optimize query when there are millions of ports

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • None
    • None
    • Poller

    Description

      With lots and lots of ports, we ended up with the query in polling/ports.inc.php taking 7 minutes!

      SELECT *, I.`port_id` AS `port_id` FROM `ports` AS I LEFT JOIN `ports-state` AS S O:qN I.`port_id` = S.`port_id` WHERE `device_id` = '866;
      136 rows in set (7 min 23.28 sec)
      ^^^^^^^^^^^^^^^

      Using a subselect instead, we got it down to a still-ridiculous 22 seconds.

      SELECT *, I.`port_id` AS `port_id` FROM (SELECT * FROM `ports` WHERE `device_id` = 866) AS I LEFT JOIN `ports-state` AS S ON I.`port_id` = S.`port_id`;
      136 rows in set (22.24 sec)
      ^^^^^^^^^

      Attachments

        Activity

          People

            landy Mike Stupalov
            fenestro Bill Fenner
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: