Can i load a 10gb database with 8gb RAM?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Can i load a 10gb database with 8gb RAM?

Post by Keya »

Im relatively new to databases, im just wondering if I can load say a 10gb SQL dump (basically just "INSERT" statements) if i only have say 8gb of RAM? If not, how to approach this?
infratec
Always Here
Always Here
Posts: 7663
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can i load a 10gb database with 8gb RAM?

Post by infratec »

It's not exactly clear what you want to do.
If you want to execute the content of the file, simply read it line by line and execute each line.
Or read and concat the lines until you find a ; at the end.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Can i load a 10gb database with 8gb RAM?

Post by Keya »

but can I execute each instruction of such a large database when the database is larger than my amount of RAM? does the database manage some sort of hard drive cache system?
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Can i load a 10gb database with 8gb RAM?

Post by NicTheQuick »

That completely depends on the database you are using. It's not a Purebasic related question in my opinion.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
ricardo_sdl
Enthusiast
Enthusiast
Posts: 141
Joined: Sat Sep 21, 2019 4:24 pm

Re: Can i load a 10gb database with 8gb RAM?

Post by ricardo_sdl »

You probably can load the entire file in memory, but it will be really slow. The operating system will use memory paging a lot. You can use infratec's suggestion and read it line by line and do your inserts, this will probably work, but it will take a lot of time. Check your database documentation, it may have some tool or command that can read the file directly and faster than using a programming language in the middle.
You can check my games at:
https://ricardo-sdl.itch.io/
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Can i load a 10gb database with 8gb RAM?

Post by Marc56us »

Unless you are using an in-memory database (like :memory: for SQLite) there is of course no problem loading more data than the amount of RAM available. The SGBD engine will swap Ram/Disk if needed.

PS.
1. For large amounts of data, you can save a lot of time by using CSV loading (i.e. LOAD DATA INFILE) rather than a succession of INSERT statements. (Data part of SQL Dump must be formated for CSV import)
2. If the database is in AUTO-COMMIT (which is often the case) you also save time (a lot) by disabling it during the loading. This is done by forcing the single transaction
BEGIN; ... Loading the database ... COMMIT; (or ROLLBACK if it failed)
Post Reply