Ad Widget

Collapse

Suggest to php/db - fetch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cristhiano
    Member
    • Nov 2007
    • 48

    #1

    Suggest to php/db - fetch

    In code of Zabbix, result of select's in DB are returned in PHP functions fetch_array (such pg_fetch_array / mysql_fetch_array). So, default parameter this functions return array with assoc and num. I suggest only use of assoc.

    File /frontend/php/include/db.inc.php line 401 change to:

    case "MYSQL":
    #$result = mysql_fetch_array($cursor);
    $result = mysql_fetch_assoc($cursor);


    case "POSTGRESQL":
    #$result = pg_fetch_array($cursor);
    $result = pg_fetch_assoc($cursor);


    case "ORACLE":
    #if(ocifetchinto($cursor, $row, OCI_ASSOC+OCI_NUM+OCI_RETURN_NULLS))
    if(ocifetchinto($cursor, $row, OCI_ASSOC+OCI_RETURN_NULLS))

    case "SQLITE3":
    if($cursor)
    {
    #$result = array_shift($cursor);
    $result=sqlite_fetch_array($cursor,SQLITE_ASSOC);
  • Niels
    Senior Member
    • May 2007
    • 239

    #2
    Are you sure this is a slow path in Zabbix?

    http://php.net/manual/en/function.my...rray.php#22361 has a benchmark from 2002, can you reproduce with current versions? Are you sure Zabbix never uses the num keys?

    I'm sorry to sound so negative, but fetch_array doesn't look particularly broken to me.

    Comment

    • cristhiano
      Member
      • Nov 2007
      • 48

      #3
      Originally posted by Niels
      Are you sure this is a slow path in Zabbix?
      For me anything is good. I have Nagios today and analize the Zabbix. My scenario: ~4500 hosts, +- 5 triggers each. Interface of Nagios is very better to manage and very fast of Zabbix. But I'm trying.

      Originally posted by Niels
      http://php.net/manual/en/function.my...rray.php#22361 has a benchmark from 2002, can you reproduce with current versions? Are you sure Zabbix never uses the num keys?
      Is very better process 5MB of SQL query instead 10MB. I'm change my Zabbix and no get problems. But, don't sure if Zabbix use num keys. Developers have sure.

      Originally posted by Niels
      I'm sorry to sound so negative, but fetch_array doesn't look particularly broken to me.

      Comment

      • cristhiano
        Member
        • Nov 2007
        • 48

        #4
        Remove get_accessible_hosts_by_user

        I remove function get_accessible_hosts_by_user in Overview Screen. As permissions are based on groups and groups are query to populate the combo of groups. So, I change functions: get_triggers_overview and get_items_data_overview to getting the results of combo and pass to next query.

        Usually there are more hosts than groups.

        The SQL query reduzed the number of "OR" and this reduzed delay to show overview.

        Comment

        • Tenzer
          Senior Member
          • Nov 2007
          • 316

          #5
          I'm sure that a diff would be the best way to show which changes you've made, and maybe they get included in Zabbix.

          Comment

          • cristhiano
            Member
            • Nov 2007
            • 48

            #6
            Here is patch (I'm use 1.5 - Overview-Hosts location-Left is very good).
            And I send diff of sql query.
            Attached Files

            Comment

            Working...