From: msi77 <msi77@yandex.ru>
To: pgsql-sql@postgresql.org
Subject: Re: short-cutting if sum()>constant
Date: Tue, 22 Dec 2009 18:11:21 +0300
Message-ID: <6521261494681@webmail110.yandex.ru> (raw)
In-Reply-To: <20091222141231.GE10308@a-kretschmer.de>
References: <20091222133527.3007bd96@dawn.webthatworks.it>
<20091222141231.GE10308@a-kretschmer.de>
Does PG support CTE?
You can try it.
> In response to Ivan Sergio Borgonovo :
> > Развернуть
> > Hi,
> >
> > I'd like to know if
> >
> > select sum(qty) from t where status=37;
> >
> > is > constant.
> >
> > qty is always >0.
> >
> > Is there a way to skip examining further rows and return a result
> > ASAP?
> I think no.
> But you can create a new table with 2 columns: status (primary key) and
> a column for the sum of qty. And you need a TRIGGER: update this table
> for every insert, update and delete on your table t.
> Now you can ask _this_ new table if the sum(qty) > your constant, this
> should work very fast.
> Just an idea...
> Andreas
>
Яндекс.Почта. Письма есть. Спама - нет. http://mail.yandex.ru/nospam/sign
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: msi77@yandex.ru
Subject: Re: short-cutting if sum()>constant
In-Reply-To: <6521261494681@webmail110.yandex.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox