MySQL
  Home arrow MySQL arrow Page 3 - Optimizing for Query Speed
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Optimizing for Query Speed
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2006-08-03

    Table of Contents:
  • Optimizing for Query Speed
  • 13.1 Index Optimization and Index Usage
  • 13.1.2 Obtaining Table Index Information
  • 13.1.3 Using Indexes
  • 13.1.3.1 Indexing Column Prefixes
  • 13.1.3.2 Leftmost Index Prefixes
  • 13.1.4 FULLTEXT Indexes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Optimizing for Query Speed - 13.1.2 Obtaining Table Index Information
    (Page 3 of 7 )

    To find out what indexes a table has, use SHOW CREATE TABLE to display the CREATE TABLE statement that corresponds to the table structure, including its indexes.

    For more detailed information about the indexes, use SHOW INDEX. For example, SHOW INDEX produces the following output for the Country table of the world database:

    mysql> SHOW INDEX FROM Country\G
    ********************* 1. row **********************
    Table: Country
    Non_unique: 0
    Key_name: PRIMARY
    Seq_in_index: 1
    Column_name: Code
    Collation: A
    Cardinality: NULL
    Sub_part: NULL
    Packed: NULL
    Null:
    Index_type: BTREE
    Comment:

    The output indicates that the table has a single index, a primary key on the Code column. The output for the City table is similar except that it indicates the ID column is the primary key:

    mysql> SHOW INDEX FROM City\G
    ********************* 1. row **********************
    Table: City
    Non_unique: 0
    Key_name: PRIMARY
    Seq_in_index: 1
    Column_name: ID
    Collation: A
    Cardinality: NULL
    Sub_part: NULL
    Packed: NULL
    Null:
    Index_type: BTREE
    Comment:

    For the CountryLanguage table, the output has two rows because the primary key includes two columns, Country and Language:

    mysql> SHOW INDEX FROM CountryLanguage\G
    ********************* 1. row ***************************
    Table: CountryLanguage
    Non_unique: 0
    Key_name: PRIMARY
    Seq_in_index: 1
    Column_name: Country
    Collation: A
    Cardinality: NULL
    Sub_part: NULL
    Packed: NULL
    Null:
    Index_type: BTREE
    Comment:
    ******************** 2. row ***************************
    Table: CountryLanguage
    Non_unique: 0
    Key_name: PRIMARY
    Seq_in_index: 2
    Column_name: Language
    Collation: A
    Cardinality: NULL
    Sub_part: NULL
    Packed: NULL
    Null:
    Index_type: BTREE
    Comment:

    The Seq_in_index values show the order of the columns within the index. They indicate that the primary key columns are Country first and Language second. This information corresponds to the following PRIMARY KEY declaration:

    PRIMARY KEY (Country, Language)

    More MySQL Articles
    More By Sams Publishing


       · This article is an excerpt from the book "MySQL Certification Guide," published by...
     

    Buy this book now. This article is excerpted from chapter 13 of the MySQL Certification Guide, written by Paul Dubois et al. (Sams, 2005; ISBN: 0672328127). Check it out today at your favorite bookstore. Buy this book now.

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway