"IN"술어를 사용하여 쿼리해야하지만 jOOQ는 "IN"을 "EXISTS"+ 2x 중첩 된 선택 항목으로 렌더링합니다. 그러나 DB2에서는 "IN"이 훨씬 빠릅니다 (500ms 대 8s). 내 "IN"술어를 DSL API를 통해 설명 할 때와 동일한 방식으로 렌더링하도록 jOOQ를 강제 적용 할 수 있습니까?jOOQ - EXISTS 대신 IN을 렌더링하십시오.
샘플 코드 :
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:")) {
Settings settings = new Settings().withRenderFormatted(true);
DSLContext ctx = DSL.using(connection, SQLDialect.SQL99, settings);
ctx
.createTable("FOOBAR")
.column("FOO", SQLDataType.INTEGER)
.column("BAR", SQLDataType.INTEGER)
.execute();
String sql = ctx
.select()
.from(DSL.tableByName("FOOBAR"))
.where(
DSL.row(DSL.fieldByName("FOO")).in(ctx
.select(DSL.fieldByName("BAR"))
.from(DSL.tableByName("FOOBAR"))
)
)
.getSQL();
System.out.println(sql);
}
결과 :
select *
from "FOOBAR"
where exists (
select "alias_2"."alias_2_0"
from (
select "BAR"
from "FOOBAR"
) "alias_2"("alias_2_0")
where ("FOO") = ("alias_2"."alias_2_0")
)
왜 DB2 방언을 사용하지 않습니까? –
무료 버전에 포함되지 않는 이유는 무엇입니까? ;) – LoganMzz
우리의 땀과 눈물이 DB2 통합 작업을하기 때문에 보상을 받아야합니다! –