From 81ec6dc8192a922663f1353c904b9747cf081d10 Mon Sep 17 00:00:00 2001 From: Fortern Date: Mon, 8 Dec 2025 13:44:20 +0800 Subject: [PATCH] prism --- PostgreSQL/prism/prism.sql | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/PostgreSQL/prism/prism.sql b/PostgreSQL/prism/prism.sql index dde2908..ef92905 100644 --- a/PostgreSQL/prism/prism.sql +++ b/PostgreSQL/prism/prism.sql @@ -2,6 +2,10 @@ select max(timestamp) from activities; +-- 获取最旧的数据 +select min(timestamp) +from activities; + -- 1天内的数据,按action分组排序 select b.action_id, b.action, count(b.action_id) from activities as a @@ -84,6 +88,16 @@ where action_id = (select action_id from actions where action = 'block-break') group by activities.cause_id, causes.cause order by count(activities.cause_id) desc; +-- 1天内,非玩家触发的 block-break 行为,按 type_id 分组 +select activities.cause_entity_type_id, entity_types.entity_type, count(*) +from activities + left join entity_types on activities.cause_entity_type_id = entity_types.entity_type_id +where action_id = (select action_id from actions where action = 'block-break') + and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 + and activities.cause_player_id is null +group by activities.cause_entity_type_id, entity_types.entity_type +order by count(activities.cause_id) desc; + -- 1天内,风弹实体触发的 block-break 行为,按坐标分组 select world_id, x, y, z, count((world_id, x, y, z)) from activities @@ -92,3 +106,40 @@ where action_id = (select action_id from actions where action = 'block-break') and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 group by world_id, x, y, z order by count((world_id, x, y, z)) desc; + +-- 查看最近风弹破换方块的数据 +select * +from activities +where action_id = (select action_id from actions where action = 'block-break') +-- and cause_entity_type_id = (select entity_type_id from entity_types where entity_type = 'breeze_wind_charge') + and cause_entity_type_id is null + and cause_player_id is null + and cause_id is null + and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 +limit 100; + +-- 1天内,发射器的数据,按发射的物品分组统计 +select descriptor, count(*) +from activities +where action_id = 2 + and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 +group by descriptor +order by count(descriptor) desc; + +-- 1天内,发射的潜影盒,按坐标分组 +select descriptor, count(*) +from activities +where action_id = 2 + and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 + and descriptor = 'Shulker Box' +group by descriptor +order by count(descriptor) desc; + +-- 1天内的 entity-death 行为按玩家分组 +select cause_player_id, players.player, count(*) +from activities + left join players on activities.cause_player_id = players.player_id +where action_id = (select action_id from actions where action = 'entity-death') + and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400 +group by cause_player_id, player +order by count(cause_player_id) desc;