Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: phranque

Message Too Old, No Replies

MySQL and slow website

Indexes?

     

Vivizimo

5:24 am on Jan 18, 2005 (gmt 0)



Hi there,

I have a website and in the last couple of years it has grown and so the amount of data. When I contacted the hosting company, they told me that using Indexes will solve the problem. Is here anybody who could help me to solve this problem? I will also copy the structure of the table that got this problem:

CREATE TABLE `news` (
`id` int(11) NOT NULL auto_increment,
`headline` varchar(80) default NULL,
`author` varchar(80) default NULL,
`category` varchar(80) default NULL,
`picture` varchar(120) default NULL,
`datum2` timestamp(14) NOT NULL,
`datum` timestamp(14) NOT NULL default '00000000000000',
`preview` text,
`tekst` text,
`story` int(11) NOT NULL default '0',
`views` int(11) default NULL,
`type` tinyint(4) NOT NULL default '1',
`lang` tinytext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1611 ;

I will be very thankful if someone can help me solve this problem.

Sincerely,
Sam

sunzon

7:20 am on Jan 18, 2005 (gmt 0)

10+ Year Member



Your ID field is an index.

To re-index your table (which improves speed and is wise to do once a month or so) you can run this command at the sql prompt:

OPTIMIZE TABLE news;

the command is pretty self explanatory.
HTH

coopster

12:53 pm on Jan 18, 2005 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, Vivizimo. And you too, sunzon!

While you are reading up on OPTIMIZE TABLE [dev.mysql.com], have a read through the section on the Speed of SELECT Queries [dev.mysql.com]. You'll find a link in there instructing

How MySQL Uses Indexes
as well as some general tips for speeding up queries on MyISAM tables.