Re: short-cutting if sum()>constant - Mailing list pgsql-sql

From msi77
Subject Re: short-cutting if sum()>constant
Date
Msg-id 6521261494681@webmail110.yandex.ru
Whole thread Raw
In response to Re: short-cutting if sum()>constant  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Responses Re: short-cutting if sum()>constant  (Andreas Kretschmer <akretschmer@spamfence.net>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: short-cutting if sum()>constant
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: short-cutting if sum()>constant