OK.

I need help with the following query:

SELECT * FROM PRODUCT WHERE DATE > ? ORDER BY PRICE;

Basically find products created since a given date and order by prices.

I could put an index of DATE, PRICE but it will have to resort to a filesort since DATE isn't a constant value.

I was thinking of using a DAY column so that I can just find values in the last day.

Then I could rewrite it as:

SELECT * FROM PRODUCT WHERE DAY = ? ORDER BY PRICE;

and place an index on DAY, PRICE at which point I'd be able to order by the index.

Which would work really well.

The problem is that at midnight there would be no results since DAY isn't really a floating window.

I could use DAY IN { ? ? } and then ORDER BY PRICE but it would have to use a filesort again.

Is there any interesting way people have solved this problem in the past?

Kevin


Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://www.feedblog.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to