Skip to content

Optimize run_stats_queries #1756

@bwbroersma

Description

@bwbroersma

This can be removed:

  • inner join
    (
    select
    domain,
    max(timestamp) as timestamp
    from
    checks_domaintestreport
    group by
    domain
    ) as rmax
    on r.domain = rmax.domain
    and r.timestamp = rmax.timestamp
  • inner join
    (
    select
    domain,
    max(timestamp) as timestamp
    from
    checks_mailtestreport
    group by
    domain
    ) as rmax
    on r.domain = rmax.domain
    and r.timestamp = rmax.timestamp
  • inner join
    (
    select
    coalesce(ipv4_addr,
    ipv6_addr) as source,
    max(timestamp) as timestamp
    from
    checks_connectiontest
    where
    finished = true
    group by
    coalesce(ipv4_addr,
    ipv6_addr)
    ) as rmax
    on coalesce(r.ipv4_addr,
    r.ipv6_addr) = rmax.source

This can be rewritten:

  • inner join
    (
    select
    coalesce(ipv4_addr,
    ipv6_addr) as source,
    max(timestamp) as timestamp
    from
    checks_connectiontest
    where
    finished = true
    group by
    coalesce(ipv4_addr,
    ipv6_addr)
    ) as rmax
    on coalesce(r.ipv4_addr,
    r.ipv6_addr) = rmax.source

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions