Query optimisation help please

Hello,

I am querying as shown below. query takes 2.6 seconds and there are +/- half million records in the statistics table and 200 odd in the business_details table

indexes are as shown. what need I do to make the query faster, please?

create statement


CREATE TABLE statistics
( Statistic_ID int(11) unsigned zerofill NOT NULL auto_increment
, Session_ID varchar(64)
, Browser varchar(256) 
, Country_of_Connection char(3) 
, Time_Into_Site datetime NOT NULL default '0000-00-00 00:00:00'
, Time_of_view datetime NOT NULL default '0000-00-00 00:00:00'
, Site_The_Visitor_Came_From varchar(64)
, Referer varchar(128)
, Domain_Viewed varchar(64)
, Page_Viewed varchar(64)
, `Subject` varchar(50) 
, `File` varchar(32)
, Main_Business_ID int(11) 
, Nearby_Business_ID int(11) 
, PRIMARY KEY  (Statistic_ID)
, KEY Domain_Viewed (Domain_Viewed)
, KEY Session_ID (Session_ID)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

query


select 
         stat.Domain_Viewed
    from
      statistics AS stat
  inner 
     join business_details AS bd
       on bd.web_url = stat.Domain_Viewed 
  where bd.business_id = 1
     group
       by stat.Session_ID

I should add that the result set is of 61525 rows and a result set of 4537 rows takes 0.2316 secs

bazz

doh!! I think I got it, though I am not getting the time it takes any more from phpMyAdmin. I’ll set up heidiSQL again and see if it gives me that.


select count(*)
   from
   statistics AS stat
 inner 
    join business_details AS bd
      on bd.web_url = stat.Domain_Viewed 
   where bd.business_id = 1


.

bazz