Hi,
In mysql server-:
How should I arrange my table to be as fast/small as possible.
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Dec 28, 2011, 10:16 PM
NOT NULLif possible. It makes everything faster and you save one bit per column.MEDIUMINTis often better thanINT.VARCHARcolumns, a fixed size record format will be used. This is much faster but may unfortunately waste some space. See section What are the different row formats? Or when to use VARCHAR/CHAR?.isamchk --analyzeon the table once it is loaded with relevant data. This updates a value for each index that tells how many rows that have the same value for this index on average. Of course, this is always 1 for unique indexes.isamchk --sort-index --sort-records=1(if you want to sort on index 1). If you have a unique index from which you want to read all records in numeric order, this is a good way to make that faster.LOAD DATA FROM INFILE. This is usually 20 times faster than using a lot ofINSERTs. If the text file isn't on the server, rcp it to the server first. See section LOAD DATA INFILE syntax. You can even get more speed when loading data to tables with many indexes by doing:- Create the table in mysql or perl with
- Do
- Use
- Insert data into the table with
- If you have pack_isam and want to compress the table, run pack_isam on it.
- Recreate the indexes with
- Do
The other possibility to get some more speed for bothCREATE TABLE...mysqladmin refresh.isamchk --keys-used=0 database/table_name. This will remove all usage of all indexes from the table.LOAD DATA INFILE....isamchk -r -q database/table_name.mysqladmin refresh.LOAD DATA FROM INFILEandINSERTis to enlarge the key buffer. This can be done with the-O key_buffer=#option to(safe)mysqld. For example 16M should be a good value if you have much RAM :)SELECT ... INTO OUTFILE. See section LOAD DATA INFILE syntax.LOCK TABLESon the tables....FROM INFILE...and...INTO OUTFILE...are atomic so you don't have to useLOCK TABLESwhen using these. See sectionLOCK TABLESsyntax.Please refer the below link
http://www.educat.hu-berlin.de/doc/mysql/MySQL_Table_efficiency.html
http://www.educat.hu-berlin.de/doc/mysql-faq.html#SEC46
Thanks