Any ideas on how to optimise this ?

2001-03-26 Thread Peter Skipworth

Hi peeps,

I've got a table which is basically a log of traffic on one of my websites
- I have a seperate table per month, all of which are MERGED for queries
which need access to more than a month's worth of data. 

select count(distinct cookie) as c,dayofmonth(event_time) as d from
tbl_webevents where event_time = '2001-02-01 00:00:00' and
event_time  '2001-03-01 00:00:00' group by d;

This query currently takes in excess of 20 seconds to return a result
(tbl_webevents is the merge table, consisting of 6 x 250,000 row table).

Does anyone have any suggestions as to whether this could be sped up ? All
ideas welcome!

Thanks,

P



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Any ideas on how to optimise this ?

2001-03-26 Thread Fred van Engen

Hi Peter,

On Mon, Mar 26, 2001 at 12:20:14PM +0100, Peter Skipworth wrote:
 I've got a table which is basically a log of traffic on one of my websites
 - I have a seperate table per month, all of which are MERGED for queries
 which need access to more than a month's worth of data. 
 
 select count(distinct cookie) as c,dayofmonth(event_time) as d from
 tbl_webevents where event_time = '2001-02-01 00:00:00' and
 event_time  '2001-03-01 00:00:00' group by d;
 

Could you post an EXPLAIN SELECT ... for this?


 This query currently takes in excess of 20 seconds to return a result
 (tbl_webevents is the merge table, consisting of 6 x 250,000 row table).
 

How long does the query take on the unmerged table for februari?
Just for comparison of course. The optimizer doesn't work as well
on MERGE tables as it does on regular tables. You might need to
explicitly tell it to use a certain index with SELECT ... FROM
tbl_webevents USE INDEX (...) WHERE ...

Could you post an EXPLAIN SELECT ... for this single table as well?


Regards,

Fred.

-- 
Fred van Engen  XO Communications B.V.
email: [EMAIL PROTECTED] Televisieweg 2
tel: +31 36 5462400 1322 AC  Almere
fax: +31 36 5462424 The Netherlands

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php