Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a really big table (approx. > 100.000.000 rows and a size of > 50GB) and it's getting a big performance kill right now. Beneath the primary key (id) it uses a fulltext key on a varchar(500) field to use the mysql fulltext search option.

However, saving and getting rows to this table is getting really slow right now.. How can I handle this? This is my first problem. My second problem is, that getting a backup with mysqldump of this table is no use, because it would take months to import it back. The third problem is, that this table uses the engine MYISAM and a conversion to INNODB is also not possible (I've tested it and aborted the proccess after 72 hours).

So, what would be a good future-proof approach to speed this table up, back it up correctly and maybe convert it to INNODB? (INNODB should accept FULLTEXT with my mysql version)

share|improve this question

migrated from stackoverflow.com Mar 6 '13 at 10:04

This question came from our site for professional and enthusiast programmers.

4 Answers 4

I'd suggest a more radical approach. For databases of your size a fulltext search is not only ineffective, but inefficient. I'm guessing that there's some kind of user-driven search function requiring your index.

How about you employ a real search engine? This would take the load of key generation and reordering off of your database. It would give you the chance to offload the load to even another machine.

Take a look at Apache Solr, a well-received, fast implementation based on Lucene. Many large non-profit and commercial websites use it with success.

Then, remove the fulltext indexing from your table. Inserts should then fly into the table with only the ID key left.

Also, if you regularily remove rows from the table, OPTIMIZE TABLE should be done regularily.

For backup purposes, you might consider replication. There are multiple ways to implement the replication, and all of them spread the load out over time, instead of creating a downtime for it, which is what you have now. As an added benefit some replications can produce a database that can be used as a stand-in replacement if the primary database fails, so that the application can be up again in little to no time.

share|improve this answer
    
I feel like Elastic Search is easier to implement than Solr (it's still lucene based in the end). Also there are cloud based services such as searchify.com to offload your document searching to (if you don't consider cloud a four letter word) –  atxdba Mar 6 '13 at 16:18

This is not a simple question and will take some more effort to answer.

For a start, please post your tables schema, so people can take a closer look.

Some general advice:

Performance

To find out what is eating your performance, try profiling your statements which are INSERTing and SELECTing rows.

Example:

  1. Turn on the profiler:

    SET profiling = 1;

  2. Execute your INSERT or SELECT statement.

  3. View the profilers result:

    SHOW PROFILES;

This will return something like this:

Query_ID |  Duration | Query
---------+-----------+-----------------------
  ...    | ...       | ...   
   29    | 0.0006200 | SHOW STATUS
   30    | 0.3600000 | (your query here)
  ...    | ...       | ...

For this example, show the details for Query_ID 30:

SHOW PROFILE FOR QUERY 30; 

...and you'll see what is the slow part of this statement. Depending on the reason you can take measures to optimize the behaviour, even if it comes down to simple hardware related things like faster hard discs etc.

Backup

With huge tables like this, conventional backups like mysqldump just take very long. You might want to consider different backup strategies. If you're using MyISAM it might be way faster using file-based backup to a different partition, then moving the files to your backup devize. You might want to search for professional alternatives, p.e. Percona XtraBackup or similar tools, too.

Another approach would be to set up replication.

InnoDB

Since MySQL 5.6 you can use fulltext on InnoDB, too. It promises significant performance boosts, which I haven't tried so far. Please be aware, this affects your system in more ways:

share|improve this answer

If your table is mainly used in WRITING actions ( INSERT / UPDATE ), you should use MyISAM.

If your table is mainly used in READING actions ( SELECT ), you should use InnoDB.

However, you should consider housekeeping your table and add appropriate index to columns.

share|improve this answer
    
I'm using MyISAM right now and nevertheless writing to the table takes too long... –  user2138834 Mar 6 '13 at 7:39
    
I know. Try housekeeping the data. (p.s. post your schema too) –  Raptor Mar 6 '13 at 7:40
    
Schema is latin1_swedish_ci. So REPAIR and OPTIMIZE should do the trick? I will try that. Are there more tricks to optimise speed? –  user2138834 Mar 6 '13 at 7:43
1  
Archive old data if there are not used. –  Raptor Mar 6 '13 at 7:45

Do you need all of the data in this table, or can you purge some of it?

If you do need access to all of the data, can you separate it into a "hot" set that you need regular access to, and a "cold" set that you need once-in-a-while access to?

What kind of queries are you running? Could you summarize some of the data in another table for querying? For example, if you are pulling counts of fields, you could just store/update the counts in another table.

Tell us more.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.