I have created a database that holds every http request that passes through a proxy server, and then made a php front end to parse, navigate and display the data. Over the course of only a few weeks, the database has balooned up to more that 4 million records. This makes many of my selections run very slowy, and I'm looking for suggestions on how to handle the situation. Here's what I have now... This table holds the IP address and Logins of the people using the proxy server. [code]-- -- Table structure for table `t_ipLogs` -- CREATE TABLE `t_ipLogs` ( `ID` int(10) unsigned NOT NULL auto_increment, `IP` tinytext NOT NULL, `Domain` tinytext NOT NULL, `Computer` tinytext NOT NULL, `Who` tinytext, `LogIn` datetime NOT NULL, `LogOut` datetime NOT NULL, `Modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `Removed` datetime NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=3312 DEFAULT CHARSET=utf8 AUTO_INCREMENT=3312 ;[/code] This table holds the list of URL's that the proxy server has blocked [code]-- -- Table structure for table `t_httpBlocks` -- CREATE TABLE `t_httpBlocks` ( `ID` mediumint(8) unsigned NOT NULL auto_increment, `Blocked` datetime NOT NULL COMMENT 'When this URL was Blocked', `URL` text NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=228866 DEFAULT CHARSET=utf8 COMMENT='Requested URL''s that were Blocked' AUTO_INCREMENT=228866 ; [/code] And this is the table that holds every http request passed through the proxy [code]-- -- Table structure for table `t_httpLogs` -- CREATE TABLE `t_httpLogs` ( `ID` mediumint(8) unsigned NOT NULL auto_increment, `blockID` mediumint(9) unsigned default NULL COMMENT 'ID of record in the Block table that matches this Request', `ipID` mediumint(8) unsigned default NULL COMMENT 'ID of record in the ipLogs table', `IP` tinytext NOT NULL COMMENT 'IP Address if the client making the Request', `Requested` datetime NOT NULL COMMENT 'When the Request was made', `Host` text NOT NULL, `Domain` tinytext NOT NULL, `URL` text NOT NULL, `Code` varchar(3) NOT NULL COMMENT 'HTTP Status Code', `Size` bigint(10) unsigned NOT NULL default '0' COMMENT 'Sice (in bytes) of the data retrieved', PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=4025737 DEFAULT CHARSET=utf8 AUTO_INCREMENT=4025737 ;[/code] I have written a perl script that monitors the proxy server's log file and inserts the records as it finds them, and that seems to run just fine, it's the PHP site which displays the records that is the problem. Some sample queries listed below takes several minutes to return results. Find the most recent 500 http requests made by the user identified in the IP Logs as "3272" [code]SELECT t_ipLogs.Who, t_httpLogs.IP, t_httpLogs.Requested, t_httpLogs.Domain, t_httpLogs.blockID, t_httpLogs.URL, t_httpLogs.Size FROM t_httpLogs LEFT OUTER JOIN t_ipLogs ON t_httpLogs.ipID = t_ipLogs.ID WHERE t_httpLogs.ipID = "3272" ORDER BY t_httpLogs.Requested DESC, t_httpLogs.ID DESC LIMIT 0,500[/code] List all IP Records for user "pseudoname" and the number of requests made in each session [code]SELECT t_ipLogs.ID, t_ipLogs.Who, t_ipLogs.LogIn, Reqs.Requests FROM t_ipLogs LEFT OUTER JOIN ( select ipID, count(*) as "Requests" from t_httpLogs group by ipID ) Reqs on t_ipLogs.ID = Reqs.ipID WHERE t_ipLogs.Who = "pseudoname" ORDER BY t_ipLogs.LogIn DESC[/code] List the most recent 500 requests made by anyone [code]SELECT t_ipLogs.ID, t_ipLogs.IP, t_ipLogs.Who, t_httpLogs.IP, t_httpLogs.Requested, t_httpLogs.Domain, t_httpLogs.blockID, t_httpLogs.URL, t_httpLogs.Size FROM t_httpLogs LEFT OUTER JOIN t_ipLogs ON t_httpLogs.ipID = t_ipLogs.ID ORDER BY t_httpLogs.Requested DESC, t_httpLogs.ID DESC LIMIT 500[/code] The server is an AMD Athlon XP 2700+ (2.1gHz) with 512megs of RAM running Debian, MySQL 5.0.24a-4, PHP 5.1.6-1 and (if it matters) Apache 2.0.55-4.1 and phpMyAdmin 2.8.2-Debian-0.2. Can anyone suggest what can be done to work with this amount of data? How can/should I restructure the tables to make things faster and more efficient? At what point should I be concerned about the size getting out of hand?