importjava.sql。*;
パブリッククラスDBTest {
public static void main(String [] args)は例外をスローします{ test(); }
public static void test(){ String URL = "jdbc:informix-sqli:// xxx:xxx / xxx:INFORMIXSERVER = xxx; DB_LOCALE = zh_CN.utf8; CLIENT_LOCALE = zh_CN.utf8; NEWCODESET = UTF8、utf8,57372; IFX_LOCK_MODE_WAIT = 100; "; 文字列USER = "xxx"; 文字列PASSWORD = "xxxxx";
String sql1 = "select count(1)from checkresult where qhdm like '4101%'";
String sql2 = "select {+ index(checkresult idx_checkresult_qhdm)} count(*)from checkresult where qhdm like concat(?、 '%')";
String sql3 = "select count(*)from checkresult where qhdm like concat(?、 '%')";
String sql4 = "select {+ index(checkresult idx_checkresult_qhdm)} count(*)from checkresult where qhdm like?|| '%'";
{ Class.forName( "com.informix.jdbc.IfxDriver");を試してください 。 接続conn = DriverManager.getConnection(URL、USER、PASSWORD); ステートメントstmt = conn.createStatement(); // 1。
double b = System.currentTimeMillis();
ResultSet rs = stmt.executeQuery(sql1);
double b1 = System.currentTimeMillis();
System.out.println( "2101% 'のような結束1:" +(b1-b));
PreparedStatement pst = conn.prepareStatement(sql2);
double b2 = System.currentTimeMillis();
System.out.println( "get pst:" +(b2-b1));
pst.setString(1、 "4101");
double b3 = System.currentTimeMillis();
System.out.println( "setString:" +(b3-b2));
double c = System.currentTimeMillis();
pst.executeQuery();
double c1 = System.currentTimeMillis();
System.out.println( "結束2+ concat(?、 '%')のようなインデックス:" +(c1-c));
pst = conn.prepareStatement(sql3);
double c2 = System.currentTimeMillis();
System.out.println( "get pst:" +(c2-c1));
pst.setString(1、 "4101");
double c3 = System.currentTimeMillis();
System.out.println( "setString:" +(c3-c2));
double d = System.currentTimeMillis();
pst.executeQuery();
double d1 = System.currentTimeMillis();
System.out.println( "
pst = conn.prepareStatement(sql4);
double d2 = System.currentTimeMillis();
System.out.println( "get pst:" +(d2-d1));
pst.setString(1、 "4101");
double d3 = System.currentTimeMillis();
System.out.println( "setString:" +(d3-d2));
double e = System.currentTimeMillis();
pst.executeQuery();
System.out.println( "結束4+インデックスのような?||%:" +(System.currentTimeMillis()-e));
} catch(Exception e){ e.printStackTrace(); } } }
========================結論========================= ================================================== ================================================== ================================================== ================================================== ============================================= ===== ================
「%」は依然としてオプティマイザの優れたテストであることがわかりますので、注意して使用してください。