How To Optimize MySQL Queries Annandale VA

MySQL is a relational database management system, or a program that allows several users to access a number of databases. Learn about MySQL queries and how to optimize them in this article.

Local Companies

ComSolution
703-914-5615
7002-E Little River Tnpk
Annandale, VA
Software Engineering Institute
703-908-8200
4301 Wilson Blvd
Arlington, VA
Jewell & Associates
877-241-6431 x 709
1332 Vanetta Lane
Vienna, VA
Advanced Systems Development Inc
703-998-3900
2800 S Shirlington RD
Arlington, VA
Computer Corporation of America Federal Sales
703-241-7830
4025 38th Pl N
Arlington, VA
Software Development & Services Corporation
703-359-1380
2200 Wilson Blvd
Arlington, VA
US 21 Computers Inc
703-522-5825
3427 Wilson Blvd
Arlington, VA
Wallace Computer Services Inc
703-247-4200
1117 19th St N
Arlington, VA
Agent Logic Inc
703-387-2400
1611 N Kent St
Arlington, VA
Intelligent Software Solutions
703-416-4111
2001 Jefferson Davis Hwy
Arlington, VA

Using indexes

Using indexes makes the query faster in the same way as an index in a book helps in looking for a particular word.

To know how and which indexes are used in a given query, use EXPLAIN command as a prefix to select query.

EXPLAIN SELECT emp_id FROM ORGN_DATA WHERE dept_code = 'IT';

This command returns following information:

Table - Which table(s) are used in the query
Type - JOIN type. Values can be system, const, eq_ref, ref, range, index, all
Possible Keys - All keys which can be used for indexes
Key - The key actually used for index
Key Length - Shorter keys are better
Ref - Other Columns used with key to get the results
Rows - Number of rows from where data will come
Extra - Extra information. Some possible values can be using index, using where, using temporary, using filesort

You should reconsider your table structure if Possible Keys contain NULL value.
A NULL value in Key field indicates no index is being used. Using no indexes will deter the performance if there are too many records in the table because, for any query, all the records will be searched for the given condition.

Use ALTER command to add index as given below:

ALTER TABLE table_name ADD INDEX (column_name);

You can do indexing on multiple columns using:

ALTER TABLE table_name ADD INDEX (column_name1,..,column_nameN);

MySQL uses leftmost prefixing, so automatically indexes will be added for column_name1, (column_name1,column_name2),...(column_name1,..,column_NameN-1). This is quite helpful in situations like searching based on surname so an index on (surname, firstname, middlename) will automatically add multiple indexes used in faster querying.

Points to remember:

Featured Local Company

ComSolution

703-914-5615
7002-E Little River Tnpk
Annandale, VA

Related Articles
- About Fans Annandale VA
A good quality chassis fan will not only make your PC cooler, but will significantly reduce its noise output too. We round up 55 fans to see which deserve to be spinning away in your PC.
- Digital Photography Equipment Annandale VA
- Accessing the Apple TV Settings Annandale VA
- Acer-Gateway Deal Annandale VA
- A Sentinel to Screen Phone Calls Annandale VA
- A guide to Windows Home Server Annandale VA
- 3G Wireless Capacities Annandale VA
- About VoIP Annandale VA
- A Tiny Silicon Clock Annandale VA
Related Articles
- About Fans Annandale VA
A good quality chassis fan will not only make your PC cooler, but will significantly reduce its noise output too. We round up 55 fans to see which deserve to be spinning away in your PC.
- Digital Photography Equipment Annandale VA
- Accessing the Apple TV Settings Annandale VA
- Acer-Gateway Deal Annandale VA
- A Sentinel to Screen Phone Calls Annandale VA
- A guide to Windows Home Server Annandale VA
- 3G Wireless Capacities Annandale VA
- About VoIP Annandale VA
- A Tiny Silicon Clock Annandale VA
Related Local Events
Human Capital Management Federal (HCMF)
Dates: 11/16/2009 - 11/18/2009
Location: Sheraton National Hotel
Arlington, VA
View Details

RFID Solutions Workshops 2007 - Toronto
Dates: 10/10/2009 - 10/11/2009
Location: Gaylord Convention Center
National Harbor, MD
View Details

Free Computer Classes @ Martin Luther King Jr. Memorial Library
Dates: 7/5/2009 - 7/5/2009
Location: MLK Jr. Memorial Library
Washington, DC
View Details

DataPoint Event - Convergence of Virtualization and VOIP
Dates: 6/4/2009 - 6/4/2009
Location: DataPoint
Baltimore, MD
View Details

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Advertising Family Home Services Real Estate Resources
Business Services Fashion Industrial Goods & Services Retail & Consumer Services
Career Financial Services Insurance Software
Cars Food & Beverage Internet Technology
Computer Hardware Franchise Legal Telecommunications
Construction Health Miscellaneous Trade Shows
Education Holidays Nightlife Travel
Entertainment Home Appliances Online Database Weddings
Environmental Home Electronics Pets World History