Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
Expand All @@ -57,6 +58,7 @@ public class JdbcRecordCursor
private final JdbcClient jdbcClient;
private final Connection connection;
private final PreparedStatement statement;
private final AtomicLong readTimeNanos = new AtomicLong(0);
@Nullable
private ResultSet resultSet;
private boolean closed;
Expand Down Expand Up @@ -117,7 +119,7 @@ else if (javaType == Slice.class) {
@Override
public long getReadTimeNanos()
{
return 0;
return readTimeNanos.get();
}

@Override
Expand All @@ -141,6 +143,7 @@ public boolean advanceNextPosition()

try {
if (resultSet == null) {
long start = System.nanoTime();
Future<ResultSet> resultSetFuture = executor.submit(() -> {
log.debug("Executing: %s", statement);
return statement.executeQuery();
Expand All @@ -166,6 +169,9 @@ public boolean advanceNextPosition()
resultSetFuture.cancel(true);
throw new RuntimeException(e);
}
finally {
readTimeNanos.addAndGet(System.nanoTime() - start);
}
}
return resultSet.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,14 @@ public void testJoinPushdown()
}
}

@Test
public void testExplainAnalyzePhysicalReadWallTime()
{
assertExplainAnalyze(
"EXPLAIN ANALYZE VERBOSE SELECT * FROM nation a",
"'Physical input read time' = \\{duration=.*}");
}

protected QueryAssert assertConditionallyPushedDown(
Session session,
@Language("SQL") String query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.spi.type.VarcharType.createVarcharType;
import static io.trino.testing.TestingConnectorSession.SESSION;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;

Expand Down Expand Up @@ -122,6 +123,8 @@ public void testCursorSimple()
.put("eleven", 11L)
.put("twelve", 12L)
.buildOrThrow());

assertThat(cursor.getReadTimeNanos()).isGreaterThan(0);
}
}

Expand Down Expand Up @@ -152,6 +155,8 @@ public void testCursorMixedOrder()
.put("eleven", 11L)
.put("twelve", 12L)
.buildOrThrow());

assertThat(cursor.getReadTimeNanos()).isGreaterThan(0);
}
}

Expand Down