Re: expected O^2 looks line K^O, index problem not involved: [was] looping simpler query just faster

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: expected O^2 looks line K^O, index problem not involved: [was] looping simpler query just faster
Дата
Msg-id 20080710135254.GB18528@svana.org
обсуждение исходный текст
Ответ на expected O^2 looks line K^O, index problem not involved: [was] looping simpler query just faster  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Ответы Re: expected O^2 looks line K^O, index problem not involved: [was] looping simpler query just faster  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Список pgsql-general
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@svana.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@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Starter
Следующее
От: aravind chandu
Дата:
Сообщение: SPACE FOR POSTGRESQL DATABASE