I have a SQLite-db with a size of 11 GB and 16 GB of RAM (shared with OS and so on). I want to perform a subsetting method with data.table:
# database connection
con = dbConnect(dbDriver("SQLite"), dbname=sqlite_database)
# read table from database
inventory <- as.data.table(dbGetQuery( con,'select * from inventory'))
# subset table
unfulfilled_inventory <- inventory[period >= stableStateStart, .(period, articleID, unfulfilledQuantities, backlog, stock)]
Getting more RAM would be the cheapest way to solve this problem, but unfortunately this is not an option.
The inventory object has 127,500,000 rows with 6 variables. The inventory object has an allocated size in memory of 5.2 GB.
dim(unfulfilled_inventory)
[1] 127500000 6
Is there a way to do this subsetting in a more memory-efficient way? I tried building a vector for vector scanning, but it has the same result. Or is there a way to use swap space for this operation (I do not really care about speed).
5.2GBhere? Also what doesdim(inventory)result in?