List:General Discussion« Previous MessageNext Message »
From:Keith C. Ivey Date:July 1 2003 4:47pm
Subject:Re: Date query optimization
View as plain text  
On 1 Jul 2003 at 9:25, Karl J. Stubsjoen wrote:

> ROWS: 34,000 + searched
> explain
> select
> a.submitid,a.url,a.submitdate,a.name,a.company,a.address1,a.city,a.sta
> te,a.z
> ipcode,a.country,a.email,a.phone,a.keywords,a.title,a.description,a.su
> bmitte dby from submit as a inner join re_idx as b on a.submitid =
> b.submitid where  year(a.submitdate)=2003 and month(a.submitdate)=7
> and dayofmonth(a.submitdate)=1; --and  year(a.submitdate)=2003 and
> month(a.submitdate)=7 and dayofmonth(a.submitdate)<15;
> 
> Notice the 2nd where statement, this is how I typically do my date
> queries (and it is slow).  This is because I might also be searching
> for a range of dates (as in the commented out "and" clause above).

The normal way to do a search for a range of dates would be 

   ... WHERE a.submitdate BETWEEN '2003-07-01' AND '2003-07-14';

Is that what you're looking for?

-- 
Keith C. Ivey <keith@stripped>
Tobacco Documents Online
http://tobaccodocuments.org

Thread
Date query optimizationKarl J. Stubsjoen1 Jul
  • Re: Date query optimizationKeith C. Ivey1 Jul
    • Re: Date query optimizationKarl J. Stubsjoen1 Jul
      • Re: Date query optimizationKeith C. Ivey1 Jul
  • RE: Date query optimizationRick Robinson2 Jul