Skip to contents

coRpusdb 0.2.0

Memory and speed on large databases, measured with bench/benchmark_memory.R (each case in its own process, peak resident memory of R and DuckDB; results in bench/results_memory.csv), and the options that projects need.

  • New free_memory_gb() and check_free_memory(); db_connect() warns when DuckDB’s memory limit exceeds the memory available, and reads the number of threads from the option coRpusdb.threads.
  • New db_check_unique(): key uniqueness checked in SQL, without loading the table.
  • New db_query_chunks(): processes a result chunk by chunk, streamed as Arrow record batches when arrow is installed (2 million texts: 5.6 s and 2.7 GB, against 10.5 s and 3.6 GB with DBI::dbFetch() chunks).
  • New draw_stratified_sample_db(): stratified sample drawn by DuckDB, reproducible on any machine (MD5 ordering); on 10 million rows, 0.8 s and 140 MB against 6.6 s and 1.3 GB when loading the population into R.
  • draw_stratified_sample() no longer copies the population: 5 times faster on 5 million rows, same samples for the same seed.
  • normalise_for_matching() decodes entities and transliterates only the strings that need it: 1 million titles in 5.8 s instead of 37 s, half the memory, same results.
  • hash_id() uses a vectorised digest (3.7 times faster).
  • replace_rows(), replace_documents() and append_raw_records() insert by column name from a registered data frame instead of copying and aligning it first; they also accept data.tables (a data.table input failed before).
  • run_in_background() and background_jobs() read their folders from the options coRpusdb.log_dir and coRpusdb.project_dir, and take their arguments in the order script, options, name; pipeline_log() and pipeline_status() read the log file from coRpusdb.pipeline_log and accept the status "warning".
  • db_query() no longer copies the result.

coRpusdb 0.1.0

First version, gathering and unifying functions copied across the author’s database projects (building_jstor_database, building_elsevier_database, building_istex_database, central_bank_database, build_eu_database, eea_history), tested on their databases.