View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 06:34 AM
Baron Schwartz
 
Posts: n/a
Default Re: Advanced Indexing

Hi Cory,

Cory Robin wrote:
> Is there a way to only include certain matching conditions
> in indexes?
>
> Example if I have a row I want to index that is mysql dates
> (2007-06-07) and I only want to include CURRENT and FUTURE
> dates in the index and ignore any past dates. Is that
> possible at all?
>
> The issue I have is that the ratio of queries on old vs.
> new data is like 1:100000. And searches would be MUCH
> faster if I could force my queries that are looking at
> current or future data to use an index that ONLY had that
> information in them..


You can't do this. The strategies to do what you want will usually involve archiving
off old data to other tables with fewer indexes, and creating a VIEW over the old and
new tables, or moving all old data to a data warehouse, or something like that.

Incidentally, this is exactly what I built MySQL Archiver to do (just released a few
days ago):

http://www.xaprb.com/blog/2007/06/06...-091-released/
http://www.xaprb.com/blog/2006/05/02...g-jobs-in-sql/
http://sourceforge.net/projects/mysqltoolkit

Baron
Reply With Quote