Ad Widget

Collapse

Inefficient queries in graphs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • safl
    Senior Member
    • May 2005
    • 103

    #1

    Inefficient queries in graphs

    Hey,

    I am having severe problems showing graphs because of some pretty demanding sql queries.

    In the file: "frontends/php/include/classes/graph.inc.php"
    line: 858, 859, 864.

    On those lines are three quite similar but a bit different versions of queries for extracting data for graphs.

    Problem is that on a 2GB history table this takes about 3 minutes to run, the server is a HP DL380 with Xeon and plenty of ram.... i haven't had the time to try and optimize the query so i post it here in hopes of someone with the time and joy for queries would like to optimize it and submit a patch of some sort.

    Regards,

    -Simon
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Wht do you think the query is unefficient? The query runs super-fast even on 20-40GB history. Perhaps your database have some missing indexes?
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • safl
      Senior Member
      • May 2005
      • 103

      #3
      You might be right!
      How can i determine if my setup is faulty?

      Comment

      • safl
        Senior Member
        • May 2005
        • 103

        #4
        Yes you were right.
        I need to add the the index "ALTER TABLE history ADD KEY itemidclock (itemid, clock)".
        How it disappeared puzzles me

        Comment

        • safl
          Senior Member
          • May 2005
          • 103

          #5
          In schema.sql there is a outcommented PRIMARY KEY why is that?
          If i may be so bold to ask

          Comment

          • Alexei
            Founder, CEO
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Sep 2004
            • 5654

            #6
            Originally posted by safl
            In schema.sql there is a outcommented PRIMARY KEY why is that?
            This is because several values may exist within a second. Usually it happens for trapped values.
            Alexei Vladishev
            Creator of Zabbix, Product manager
            New York | Tokyo | Riga
            My Twitter

            Comment

            • safl
              Senior Member
              • May 2005
              • 103

              #7
              Ahh thx.
              And thx for the help.

              Comment

              Working...