Database Design Performance Tips
2010/05/12 03:55
瀏覽760
迴響0
推薦1
引用0
Database Design Performance Tips:
- Design sane query schemas. don't be afraid of table joins, often they are faster than denormalization
- Don't use boolean flags
- Use Indexes
- Don't Index Everything
- Do not duplicate indexes
- Do not use large columns in indexes if the ratio of SELECTs:INSERTs is low.
- be careful of redundant columns in an index or across indexes
- Use a clever key and ORDER BY instead of MAX
- Normalize first, and denormalize where appropriate.
- Databases are not spreadsheets, even though Access really really looks like one. Then again, Access isn't a real database
- use INET_ATON and INET_NTOA for IP addresses, not char or varchar
- make it a habit to REVERSE() email addresses, so you can easily search domains (this will help avoid wildcards at the start of LIKE queries if you want to find everyone whose e-mail is in a certain domain)
- A NULL data type can take more room to store than NOT NULL
- Choose appropriate character sets & collations -- UTF16 will store each character in 2 bytes, whether it needs it or not, latin1 is faster than UTF8.
- Use Triggers wisely
- use min_rows and max_rows to specify approximate data size so space can be pre-allocated and reference points can be calculated.
- Use HASH indexing for indexing across columns with similar data prefixes
- Use myisam_pack_keys for int data
- be able to change your schema without ruining functionality of your code
- segregate tables/databases that benefit from different configuration variables
REF:http://blog.jaric.tw/2009/04/08/top-10-sql-performancetips/
你可能會有興趣的文章:



