-4

I have some simple code that generates 3 millions insert queries.

I have two VPSes, one with 512MB RAM and one with 2GB RAM. On the 512MB RAM VPS, I can insert about 50,000 rows in 5 minutes. On the larger VPS, I can insert 1 million rows in the same time.

Is RAM size related to SQL performance?

Is true that the more RAM the VPS offers, the faster the queries?


I agree with MDMarra,

"That said, you can have all the RAM in the world and have low disk IO throughput and be worse off. It depends on your workload."

But, generally, all the hosting providers on higher plans offer more RAM and more disk performance. So, the final questions is: Is true that buying an excellent vps plan will guarantee excellent sql queries performances?

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • The only answer that can be given to your first question: "Is RAM size related to SQL performance" is "Yes." But then you changed your question to "Will buying an excellent VPS plan guarantee excellent SQL performance," and that is a solid "Depends." You're not really asking anything concrete that we can objectively answer. – Ryan Ries Feb 23 '14 at 01:42
  • Yes/No/Maybe - there are way too many variables. – user9517 Feb 23 '14 at 07:36

2 Answers2

4

Your performance difference has a simpler explanation. You are doing synchronous inserts. Your VPS with 512MB of RAM has a 10,000 RPM disk drive and so can complete about 10,000 synchronous writes per minute. Your VPS with 2GB either has an SSD, is configured not to do synchronous inserts, or is ignoring the request to perform writes synchronously. So it does the writes much faster.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84
0

No, it is not true by definition. But more RAM will then allow you to adjust settings that can move more operations into RAM and improve performance. Depends on the environment though and is probably going to work a tad more effectively if your tables are innodb.

Peter
  • 1,450
  • 2
  • 17
  • 27