私はPostgresにかなり慣れていないので、2つの別々のデータを取得する必要があります.最近のタイムスタンプ
問題は、パフォーマンスの問題が発生するため、これらのクエリを個別に実行できないことです。(このテーブルのデータは、数万またはレコードになる可能性があり、それらを結果オブジェクトに結合すると、さらに複雑になります)。
これら 2 つのデータの結果を並べて組み合わせて、目的の出力を返すクエリの 1 つのモンスターにすることは可能ですか?
あなたの助けに感謝。
クエリで更新:
最初のクエリ:
select
rtp.id, rtp.received_timestamp,
rtp.agent_time, rtp.sourceip, rtp.destip, rtp.sourcedscp,
sum(rtp.numduplicate) as dups, avg(rtp.numduplicate) as avgdups,
min(rtp.numduplicate) as mindups, max(rtp.numduplicate) as maxdups
from rtp_test_result rtp
where
rtp.received_timestamp between 1274723208 and 1475642299
group by rtp.sourceip, rtp.destip, rtp.sourcedscp
order by rtp.sourceip, rtp.destip, rtp.sourcedscp
2 番目のクエリ:
select id, received_timestamp, numooo
from rtp_test_result
where received_timestamp = (select max(received_timestamp) mrt from rtp_test_result)
group by id,received_timestamp, numooo
order by id desc limit 1