Learn R Programming

DatabaseConnector (version 6.3.3)

extractQueryTimes: Extract query times from a ParallelLogger log file

Description

When using the ParallelLogger default file logger, and using options(LOG_DATABASECONNECTOR_SQL = TRUE), DatabaseConnector will log all SQL sent to the server, and the time to get a response.

This function parses the log file, producing a data frame with time per query.

Usage

extractQueryTimes(logFileName)

Value

A data frame with queries and their run times in milliseconds.

Arguments

logFileName

Name of the ParallelLogger log file. Assumes the file was created using the default file logger.

Examples

Run this code

connection <- connect(dbms = "sqlite", server = ":memory:")
logFile <- tempfile(fileext = ".log")
ParallelLogger::addDefaultFileLogger(fileName = logFile, name = "MY_LOGGER")
options(LOG_DATABASECONNECTOR_SQL = TRUE)

executeSql(connection, "CREATE TABLE test (x INT);")
querySql(connection, "SELECT * FROM test;")

extractQueryTimes(logFile)

ParallelLogger::unregisterLogger("MY_LOGGER")
unlink(logFile)
disconnect(connection)

Run the code above in your browser using DataLab