I want to create a flexdashboard that will show data from a large (5Gb) SQLite database. I placed JUST the
DBI::dbConnect on the global chunk in order to establish the connection for all other parts in the code but I'm not retrieving any data at this step. With this, the dashboard takes 30 second to start. If I remove the
DBI::dbConnect from the global chunk, the dashboard starts in a couple of seconds.
Connecting to the database in R Console, with
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = 'my_large_db.sqlite) also takes less than a second.
Why is it so slow when doing it in flexdashboard global chunk? Any suggestions on how to speed things up? In the future, I plan on moving the data to a PostgreSQL server. But for now I'm using SQLite.
PS - Just found out that it does not matter if the
DBI::dbConnect call is inside the global chunk or any other chunk. Whenever I try to open the connection, flexdashboard takes 30 seconds to load.