我正在将JOOQ与Postgres方言结合使用以从我的spring boot应用程序中触发查询,而RDS是postgres。
触发的查询是-
select contents::jsonb #> '{columns,0}'
from nebula.test where (id=4)
Java辅助代码:
Field<Object> selectField = DSL.field("contents::jsonb #> {0}",Object.class, DSL.inline("{columns,0}"));
SelectConditionStep<Record1<Object>> resultQuery= dslContext.select(selectField).from("test").where("id=4");
Result<Record1<Object>> result = resultQuery.fetch();
Jooq Loglisteners的统计信息:
o.j.t.LoggerListener : Executing query : select contents::jsonb #> '{columns,0}' from test where (id=4)
DEBUG [http-bio-8443-exec-6] -
o.j.t.StopWatch : Query executed : Total: 8.024ms
直接在Postgres中解释的统计信息
explain analyze
select contents::jsonb #> '{columns,0}' from test where (id=4);
Index Scan using test_pkey on test (cost=0.13..8.15 rows=1 width=32) (actual time=0.114..0.116 rows=1 loops=1)
Index Cond: (id = 4)
Planning time: 0.091 ms
Execution time: 0.089 ms
为什么Jooq LogListener会显示一些额外的时间?