tags:

views:

367

answers:

5

I ran a lookup test against an indexed MySQL table containing 20,000,000 records, and according to my results, it takes 0.004 seconds to retrieve a record given an id--even when joining against another table containing 4,000 records. This was on a 3GHz dual-core machine, with only one user (me) accessing the database. Writes were also fast, as this table took under ten minutes to create all 20,000,000 records.

Assuming my test was accurate, can I expect performance to be as as snappy on a production server, with, say, 200 users concurrently reading from and writing to this table?

I assume InnoDB would be best?

+5  A: 

That depends on the storage engine you're going to use and what's the read/write ratio.

InnoDB will be better if there are lot of writes. If it's reads with very occasional write, MyISAM might be faster. MyISAM uses table level locking, so it locks up whole table whenever you need to update. InnoDB uses row level locking, so you can have concurrent updates on different rows.

InnoDB is definitely safer, so I'd stick with it anyhow.

BTW. remember that right now RAM is very cheap, so buy a lot.

vartec
Adding to what vartec said: When you're picking the right engine for your job, don't forget that if you ever want to use MySQL's FULLTEXT search feature, you'll need MyISAM.
brianreavis
A: 

As long as your schema design and DAL are constructed well enough, you understand query optimization inside out, can adjust all the server configuration settings at a professional level, and have "enough" hardware properly configured, yes (except for sufficiently pathological cases).

Same answer both engines.

le dorfier
+3  A: 

Depends on any number of factors:

  • Server hardware (Especially RAM)
  • Server configuration
  • Data size
  • Number of indexes and index size
  • Storage engine
  • Writer/reader ratio

I wouldn't expect it to scale that well. More importantly, this kind of thing is to important to speculate about. Benchmark it and see for yourself.

Regarding storage engine, I wouldn't dare to use anything but InnoDB for a table of that size that is both read and written to. If you run any write query that isn't a primitive insert or single row update you'll end up locking the table using MyISAM, which yields terrible performance as a result.

Emil H
A: 

You should probably perform a load test to verify, but as long as the index was created properly (meaning indexes are optimized to your query statements), the SELECT queries should perform at an acceptable speed (the INSERTS and/or UPDATES may be more of a speed issue though depending on how many indexes you have, and how large the indexes get).

OneNerd
+2  A: 

There's no reason that MySql couldn't handle that kind of load without any significant issues. There are a number of other variables involved though (otherwise, it's a 'how long is a piece of string' question). Personally, I've had a number of tables in various databases that are well beyond that range.

  • How large is each record (on average)
  • How much RAM does the database server have - and how much is allocated to the various configurations of Mysql/InnoDB.

A default configuration may only allow for a default 8MB buffer between disk and client (which might work fine for a single user) - but trying to fit a 6GB+ database through that is doomed to failure. That problem was real btw - and was causing several crashes a day of a database/website till I was brought in to trouble-shoot it.

If you are likely to do a great deal more with that database, I'd recommend getting someone with a little more experience, or at least oing what you can to be able to give it some optimisations. Reading 'High Performance MySQL, 2nd Edition' is a good start, as is looking at some tools like Maatkit.

Alister Bulman
-> How large is each record (on average)Aren't records always the same size, so MySQL can skip a row by increasing a pointer?
Bart van Heukelom
Fixed sized records are possible, but they don't have to be - a varchar will only take as much as it needs. Also, a TEXT field (or similar) might be stored elsewhere in the file - at least for some engines.
Alister Bulman