Can i load a 10gb database with 8gb RAM?
Can i load a 10gb database with 8gb RAM?
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?
			
			
									
									
						Re: Can i load a 10gb database with 8gb RAM?
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.
			
			
									
									
						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.
Re: Can i load a 10gb database with 8gb RAM?
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?
			
			
									
									
						- NicTheQuick
- 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?
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 
- Posts: 141
- Joined: Sat Sep 21, 2019 4:24 pm
Re: Can i load a 10gb database with 8gb RAM?
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/
						https://ricardo-sdl.itch.io/
Re: Can i load a 10gb database with 8gb RAM?
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)
			
			
									
									
						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)


