From 626077189d42588726768a223a96d62c25b1cc25 Mon Sep 17 00:00:00 2001 From: Ronan Arraes Jardim Chagas Date: Sat, 23 Sep 2023 15:19:46 -0300 Subject: [PATCH 1/3] Precompile DBInterface.execute Closes #371 --- src/ODBC.jl | 2 ++ src/precompile.jl | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/precompile.jl diff --git a/src/ODBC.jl b/src/ODBC.jl index fbf612f..c0c43be 100644 --- a/src/ODBC.jl +++ b/src/ODBC.jl @@ -202,4 +202,6 @@ CTRL then right-clicking on the terminal/Julia application and choosing "Run as """ removedsn(name) = API.removedsn(name) +include("precompile.jl") + end #ODBC module diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 0000000..3b0de6d --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,9 @@ +# Precompilation directives for ODBC.jl. + +function _precompile() + ccall(:jl_generating_output, Cint, ()) == 1 || return nothing + + precompile(DBInterface.execute, (Connection, String)) +end + +_precompile() From b80bac0da2a8705e49c9dc301f6a91cca9a9e5ad Mon Sep 17 00:00:00 2001 From: Ronan Arraes Jardim Chagas Date: Sun, 24 Sep 2023 17:30:10 -0300 Subject: [PATCH 2/3] Remove precompilation statements They were adding a huge amount of time during the package loading. --- src/ODBC.jl | 2 -- src/precompile.jl | 9 --------- 2 files changed, 11 deletions(-) delete mode 100644 src/precompile.jl diff --git a/src/ODBC.jl b/src/ODBC.jl index c0c43be..fbf612f 100644 --- a/src/ODBC.jl +++ b/src/ODBC.jl @@ -202,6 +202,4 @@ CTRL then right-clicking on the terminal/Julia application and choosing "Run as """ removedsn(name) = API.removedsn(name) -include("precompile.jl") - end #ODBC module diff --git a/src/precompile.jl b/src/precompile.jl deleted file mode 100644 index 3b0de6d..0000000 --- a/src/precompile.jl +++ /dev/null @@ -1,9 +0,0 @@ -# Precompilation directives for ODBC.jl. - -function _precompile() - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - - precompile(DBInterface.execute, (Connection, String)) -end - -_precompile() From 1e70059a90f81d5c5cef79ea3a01d05670d83abd Mon Sep 17 00:00:00 2001 From: Ronan Arraes Jardim Chagas Date: Sun, 24 Sep 2023 17:30:40 -0300 Subject: [PATCH 3/3] Reduce precompilation time in the function Buffer We rewrote the function to create a Buffer to reduce the compilation time. --- src/utils.jl | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 35b5c62..3f5d9aa 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -116,33 +116,38 @@ mutable struct Buffer # for data fetching function Buffer(ctype::API.SQLSMALLINT, columnsize, rows, nullable) - if ctype == API.SQL_C_DOUBLE - return new(newarray(Float64, nullable, rows)) + T = if ctype == API.SQL_C_DOUBLE + Float64 elseif ctype == API.SQL_C_FLOAT - return new(newarray(Float32, nullable, rows)) + Float32 elseif ctype == API.SQL_C_STINYINT - return new(newarray(Int8, nullable, rows)) + Int8 elseif ctype == API.SQL_C_SSHORT - return new(newarray(Int16, nullable, rows)) + Int16 elseif ctype == API.SQL_C_SLONG - return new(newarray(Int32, nullable, rows)) + Int32 elseif ctype == API.SQL_C_SBIGINT - return new(newarray(Int64, nullable, rows)) + Int64 elseif ctype == API.SQL_C_BIT - return new(newarray(Bool, nullable, rows)) + Bool elseif ctype == API.SQL_C_TYPE_DATE - return new(newarray(API.SQLDate, nullable, rows)) + API.SQLDate elseif ctype == API.SQL_C_TYPE_TIMESTAMP - return new(newarray(API.SQLTimestamp, nullable, rows)) + API.SQLTimestamp elseif ctype == API.SQL_C_TYPE_TIME - return new(newarray(API.SQLTime, nullable, rows)) + API.SQLTime elseif ctype == API.SQL_C_GUID - return new(newarray(UUID, nullable, rows)) + UUID else + nothing + end + + if T === nothing return new(Vector{UInt8}(undef, columnsize * rows)) end - end + return new(newarray(T, nullable, rows)) + end end Base.pointer(b::Buffer) = specialize(pointer, b.buffer)