Re: two sums in one query

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: two sums in one query
Дата
Msg-id 20050708155550.GA28683@wolff.to
обсуждение исходный текст
Ответ на Re: two sums in one query  (PFC <lists@boutiquenumerique.com>)
Список pgsql-sql
On Fri, Jul 08, 2005 at 16:49:44 +0200, PFC <lists@boutiquenumerique.com> wrote:
> 
> >>SELECT (SELECT sum(amount) FROM table WHERE debit=X) AS debit, (SELECT
> >>sum(amount) FROM table WHERE credit=x) AS credit;
> >
> >If most of the records are credits or debits you don't want to do this.
> >A single sequential scan through the table will be the best plan.
> 
>     I thought that debit = source account # and credit = dest account #, 
>     and  there are a lot of different account...

You aren't likely to see a significant speed up in that case either.


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

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: Make COUNT(*) Faster?
Следующее
От: Steve Wampler
Дата:
Сообщение: Re: Make COUNT(*) Faster?