x
Loading
 Loading
Hello, Guest | Login | Register

Sample Story Outline

An outline should read as fluidly as a story. Don’t write a college outline. Instead, focus on the most important things you want to say and then state and explain those things, using examples and data to demonstrate your points. Use sidebars to discuss relevant but tangential topics.

Title: Making Optimal Use of MySQL( or maybe” Optimizing MySQL Queries”)

Goal

After reading this article, you should understand how to design you MySQL databases and write your queries so that your applications are efficient.

Required Knowledge

I will assume that you have very basic knowledge of MySQL, the SQL language, and relational database principles such as data normalization. You will not need access to your MySQL server’s configuration settings to make use of these techniques.( I will delve into MySQL server tuning next time.)

Sample Data

Introduce the” music” database that will be used in concrete examples. The schema for the tables will appear once as a figure. The database will contain four tables: albums, artists, tracks, and genres.

Article Body( the real HOWTO stuff)

Database Design Tips

1. Only store what you need.
While it may seem like common sense, it’s important to think about the data you need to store when you design a database. Needlessly storing information which can be constructed later may result in decreased performance.
2. Normalize your schema
Having a set of normalized tables will help to reduce duplication of data( and the related disk space). It will also give you a lot of flexibility in writing queries.
3. Use Indexes where appropriate
Indexing the right data is probably the single most important thing you can do to increase the performance of queries in MySQL. Because it’s so important, I’ll dig into how you should decide which columns to index.
A.How MySQL Uses Indexes
B.How Indexes Work
C.Using EXPLAIN
4. Don’t overuse indexes
Having sung the praises of indexes, you might feel compelled to index every column you might have an a WHERE clause. Don’t. The performance boost that indexes can give your SELECT queries does not come without a price. Indexes slow down INSERT, UPDATE, REPLACE, and DELETE queries.
5. Compress BLOB data
Because MySQL uses normal files for tables and indexes, your operating system, presumably Linux, will cache frequently accessed data( tables rows and indexes) in RAM to improve performance. So it’s important that you do what you can to reduce the size of the rows in your tables–especially tables which contain BLOB data which may be quite large.
6. Data Retrieval Tips
A.Only ask for what you need
Just like saying” only store what you need”, this may seem like common sense. But often times it is overlooked. Don’t use” SELECT*” on a table with 20 columns if you only need data from 2 of them. Often times I use” SELECT*” when coding because I lazy or I just don’t know which rows I’ll need quite yet. But I don’t always think to go back and make those queries leaner. The end result is that MySQL goes to the effort of retrieving far more data than I actually need. That effort amounts to wasted CPU cycles.
B.Ask Your DBA for Help
slow query log
optimize tables periodically
replication

Conclusion

Using the tips and techniques I’ve presented, you can go a long way toward having a MySQL-based application which performs well as the size of your data and your user base grow.
Next time I’ll discuss what you can do to tune the MySQL server itself, assuming you have access to the server.

Sidebars

1. The Query Optimizer
2. Understanding Join Types
Community Tools
RSS
Recommend This [?]
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Users That Liked This [?]
No one yet. Be the first.
Tags:
Tag This!
 No Comments

Now entering its eighth year of continuous publication, Linux Magazine presents the broadest and most in-depth coverage of all things Linux — from the Linux operating system, to desktop and server hardware, to open source software in the enterprise.

Written by experts and open source community leaders, each month’s Linux Magazine offers Linux professionals — programmers, system administrators, webmasters, IT managers, and business leaders — pragmatic, insightful, and solutions-oriented information.

Linux Magazine provides an information resource for a diverse open source community.

For more information about the magazine and its readership, please download the the PDF version of the 2007 Linux Magazine Media Kit. The Media Kit includes the 2007 Editorial Calendar.

Please contact Robert Wells, Vice President of Business Development for online and print advertising programs, a current rate card, outreach campaigns, and other marketing opportunities.

Read More
  1. Filenames by Design, Part Two
  2. Shades of Greylisting
  3. What's the diff?
  4. Filenames by Design, Part One
  5. Network Block Devices: Using Hardware Over a Network

Comments on Sample Story Outline

No comments yet.

Sorry, the comment form is closed at this time.

ActivSupport
Linux Magazine has chosen ActivSupport as IT consultants.
Sponsored Links