需要进行LEFT JOIN关联查询,A,B表记录数大概都在100W左右。
SQL查询原形为:
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);