private void logQueryDuration(final ExecuteContext ctx, final Duration duration) {
        // Could make this configurable but would have to move it out of util
        if (duration.compareTo(SLOW_QUERY_DURATION_THRESHOLD) >= 0) {
            if (ctx.query() != null) {
                LOGGER.debug("""
                                SQL of type {} took longer than {} to execute {}
                                {}
                                rows: {}""",
                        ctx.type(),
                        SLOW_QUERY_DURATION_THRESHOLD,
                        duration,
                        ctx.query(),
                        ctx.rows());
            } else if (ctx.batchQueries() != null) {
                // This is where you have multiple distinct queries in the batch,
                // e.g. an insert and an update
                final Query[] batchQueries = ctx.batchQueries();
                final String allSql = batchQueries.length == 0
                        ? "[NO BATCH QUERIES]"
                        : IntStream.range(0, batchQueries.length)
                                .limit(MAX_QUERY_COUNT)
                                .boxed()
                                .map(i -> {
                                    final Query batchQuery = batchQueries[i];
                                    final String sql = batchQuery.toString();
                                    final int rows = ctx.batchRows()[i];
                                    final int queryNo = i + 1;
                                    return "Query "
                                            + queryNo
                                            + ":\n"
                                            + sql
                                            + ";\nrows:"
                                            + rows;
                                })
                                .collect(Collectors.joining("\n---\n"));
                final String limitText = batchQueries.length > MAX_QUERY_COUNT
                        ? " (only showing first " + MAX_QUERY_COUNT + " queries)"
                        : "";

                LOGGER.debug("""
                                Batch of {} SQL statements took longer than {} to execute {}{}
                                {}""",
                        batchQueries.length,
                        SLOW_QUERY_DURATION_THRESHOLD,
                        duration,
                        limitText,
                        allSql);
            } else {
                LOGGER.debug("Unknown SQL of type {} took longer than 2s to execute {}",
                        ctx.type(),
                        duration);
            }
        }
    }
Logs any sql statements that take longer than 2s to execute.
Enable this by setting {@link SlowQueryExecuteListener} to DEBUG.
stroom-db-util/src/main/java/stroom/db/util/SlowQueryExecuteListener.java