Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-26769

Remove slow "or" conditions from "in" statements

XMLWordPrintable

    • S25-W32/33

      Zabbix server, Zabbix proxy and frontend can generate such queries in some places where select in batches is not performed:

      SELECT * FROM table
      WHERE id IN (1, 2, ..., 1000)
         OR id IN (1001, 1002, ..., 2000)
      

      However especially on PostgreSQL they are known to work extremely slow, recent example:
      ZBX-26732

      They should be simplified so that database engine can analyze them easier and perform fast and efficiently:

      SELECT * FROM table WHERE id IN (1, 2, ..., 1000,1001, 1002, ..., 2000)
      

      MySQL can also optimize queries with or conditions into single in but there is not reason to put strain on MySQL to do this work and it's much faster with single in statement. SQLite3 can work old way with or if needed.
      Also please see ZBX-24435

            wiper Andris Zeila
            vso Vladislavs Sokurenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: