On Thu, Jul 10, 2008 at 02:19:30PM +0200, Ivan Sergio Borgonovo wrote:
> On Thu, 10 Jul 2008 11:50:01 +0200
> Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
Hmm, I just studied your query to determine what you're trying to do.
As I understand it:
For each item
Determine the brand
Get the top three items for this brand
If this item is one of them, display it
This is pretty inefficient but I can't see an efficient way to do it
either. I suppose one thing to try would be a multicolumn index on
(brand,datainserimento) to avoid the sort step. Also, the table b1 in
the original query is redundant.
It's the fact that you want the top three items that makes it
difficult, not sure how to deal with that.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.