Ad Widget

Collapse

select value from history where itemid=nn order by clock desc limit 5

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fserto
    Junior Member
    • Jun 2009
    • 7

    #1

    select value from history where itemid=nn order by clock desc limit 5

    Hi,

    Does anyone know how I can change this query to add 'and clock > (today - 1 week)'?

    this keeps popping up on my postgresql logs:

    2010-09-30 21:05:10 EST LOG: duration: 21381.513 ms statement: select value from history where itemid=70821 order by clock desc limit 5

    and I believe this query is slowing everything down here.

    what is this query for? we have 50K items on this db, and each of these selects are taking up to 40-50 seconds.

    We're running zabbix 1.8.1.

    Cheers,
    Fernando
  • danrog
    Senior Member
    • Sep 2009
    • 164

    #2
    Add this:
    Code:
    WHERE
    clock >= unix_timestamp(timestampadd(day,"-7",now()))

    Comment

    • fserto
      Junior Member
      • Jun 2009
      • 7

      #3
      Originally posted by danrog
      Add this:
      Code:
      WHERE
      clock >= unix_timestamp(timestampadd(day,"-7",now()))
      Do you know which file? I found a few "select value from history" on evalfunc.c, but not sure if I can break things by changing that.

      Comment

      Working...