오라클에서는 hint를 이용해서 처리하는데 postgres에서는 어떻게 하는 지 궁금합니다. 다음과 같이
처리하는 경우에는 처리결과가 5분이나 걸리더라구요..(총 각 테이블마다 약 4만건의 데이터 있음)
현재 jdbc이용하여 java로 postgresql db를 access하고 있고 각 테이블마다 인덱스는 걸려
있습니다.
public TelnetLogPanelModel() {
try {
Class.forName("postgresql.Driver");
String url = "jdbc:postgresql://192.168.1.66/test";
String usr = "kkk";
String passwd = "1234";
Connection connect = DriverManager.getConnection(url, usr, passwd);
Statement state = connect.createStatement();
String query = null;
query = "select ip_src0, ip_src1, ip_src2, ip_src3, th_sport, ip_dst0, ip_dst1, ip_dst2, ip_dst3, th_dport, timestamp from iphdr, tcphdr, event where iphdr.sid = tcphdr.sid and iphdr.cid = tcphdr.cid and iphdr.sid = event.sid and iphdr.cid = event.cid and tcphdr.sid = event.sid and tcphdr.cid = event.cid ;";
ResultSet result = state.executeQuery(query);
metaData = result.getMetaData();
int numberOfColumns = metaData.getColumnCount();
columnNames = new String[numberOfColumns];
for ( int col = 0; col<numberOfColumns; col++ ) {
columnNames[col] = metaData.getColumnLabel(col+1);
}
while ( result.next() ){
int ip_src0 = result.getInt("ip_src1");
int ip_src1 = result.getInt("ip_src1");
int ip_src2 = result.getInt("ip_src2");
int ip_src3 = result.getInt("ip_src3");
int th_sport = result.getInt("th_sport");
int ip_dst0 = result.getInt("ip_dst0");
int ip_dst1 = result.getInt("ip_dst1");
int ip_dst2 = result.getInt("ip_dst2");
int ip_dst3 = result.getInt("ip_dst3");
int th_dport = result.getInt("th_dport");
Timestamp timestamp = result.getTimestamp("timestamp");
Vector newRow = new Vector();
for ( int i=1; i<=getColumnCount(); i++ ) {
newRow.addElement (result.getObject(i));
}
rows.addElement(newRow);
}
result.close();
state.close();
connect.close();
} catch(Exception e) {
System.out.println("Unable to connect DataBase");
e.printStackTrace();
}
}
//위의 sql중 어느 부분을 변경해야 할까요.....
//where조건절에 기술된 필드들은 모두 인덱스가 걸려 있습니다.
|