972
社区成员




select an.time an_time,an.host an_host,an.tid an_tid,
an.client_ip an_client_ip,an.client_port an_client_port,
an.server_ip an_server_ip, an.server_port an_server_port,
an.up an_up, an.down an_down, an.connect_time an_connect_time,
an.disconnect_time an_disconnect_time, an.duration an_duration,
an.target_type an_target_type,an.target_ip an_target_ip, an.target_port an_target_port,
an.syn_rtt an_syn_rtt,an.error_info an_error_info,
bn.time bn_time,bn.host bn_host,bn.tid bn_tid,
bn.client_ip bn_client_ip,bn.client_port bn_client_port,
bn.server_ip bn_server_ip, bn.server_port bn_server_port,
bn.up bn_up, bn.down bn_down, bn.connect_time bn_connect_time,
bn.disconnect_time bn_disconnect_time, bn.duration bn_duration,
bn.target_type bn_target_type,bn.target_ip bn_target_ip, bn.target_port bn_target_port,
bn.syn_rtt bn_syn_rtt,bn.error_info bn_error_info
from logsys.a an left join
logsys.b bn on an.tid = bn.tid and an.target_ip = bn.target_ip
where an.time >= 0 and an.time < 1408515318001 and bn.syn_rtt >= 1 and bn.syn_rtt < 10000
and bn.down >= 100 and bn.down < 1000 and (an.host = 0 or bn.host= 0);
select an.*,
bn.time bn_time,bn.host bn_host,bn.tid bn_tid,
bn.client_ip bn_client_ip,bn.client_port bn_client_port,
bn.server_ip bn_server_ip, bn.server_port bn_server_port,
bn.up bn_up, bn.down bn_down, bn.connect_time bn_connect_time,
bn.disconnect_time bn_disconnect_time, bn.duration bn_duration,
bn.target_type bn_target_type,bn.target_ip bn_target_ip, bn.target_port bn_target_port,
bn.syn_rtt bn_syn_rtt,bn.error_info bn_error_info
from (
select an.time an_time,an.host an_host,an.tid an_tid,
an.client_ip an_client_ip,an.client_port an_client_port,
an.server_ip an_server_ip, an.server_port an_server_port,
an.up an_up, an.down an_down, an.connect_time an_connect_time,
an.disconnect_time an_disconnect_time, an.duration an_duration,
an.target_type an_target_type,an.target_ip an_target_ip, an.target_port an_target_port,
an.syn_rtt an_syn_rtt,an.error_info an_error_info
from logsys.A an where an.time >= 0 and an.time < 1408515328001
) an
left join logsys.B bn on an_tid = bn.tid
where bn.syn_rtt >= 1 and bn.syn_rtt < 10000
and bn.down >= 100 and bn.down < 1000 and (an_host = 0 or bn.host= 0);
select an.time an_time,an.host an_host,an.tid an_tid,
an.client_ip an_client_ip,an.client_port an_client_port,
an.server_ip an_server_ip, an.server_port an_server_port,
an.up an_up, an.down an_down, an.connect_time an_connect_time,
an.disconnect_time an_disconnect_time, an.duration an_duration,
an.target_type an_target_type,an.target_ip an_target_ip, an.target_port an_target_port,
an.syn_rtt an_syn_rtt,an.error_info an_error_info,
bn.time bn_time,bn.host bn_host,bn.tid bn_tid,
bn.client_ip bn_client_ip,bn.client_port bn_client_port,
bn.server_ip bn_server_ip, bn.server_port bn_server_port,
bn.up bn_up, bn.down bn_down, bn.connect_time bn_connect_time,
bn.disconnect_time bn_disconnect_time, bn.duration bn_duration,
bn.target_type bn_target_type,bn.target_ip bn_target_ip, bn.target_port bn_target_port,
bn.syn_rtt bn_syn_rtt,bn.error_info bn_error_info
from logsys.A an left join
logsys.B bn on an.tid = bn.tid and an.target_ip = bn.target_ip
where an.time >= 0 and an.time < 1408515318001 and bn.syn_rtt >= 1 and bn.syn_rtt < 10000
and bn.down >= 100 and bn.down < 1000 and (an.host = 0 or bn.host= 0);
用子查询的方式,主要是可以把A表的记录数减到很少,因为在里面按时间过滤掉了,是否这样会改善很多。