Re: How do I optimize this?

From: Wei Weng <wweng(at)kencast(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How do I optimize this?
Date: 2009-03-17 22:37:05
Message-ID: 49C02611.7020104@kencast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I made a mistake in the queries:

They should be

update T set t1 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da =
1) as b where tkey = <value>;
update T set t2 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da =
2) as b where tkey = <value>;
...
update T set t10 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da =
10) as b where tkey = <value>;

Thanks
Wei

On 03/17/2009 05:43 PM, Wei Weng wrote:
> Hi all.
>
> I have the following scenario:
>
> A table T (int t1; int t2; ... int t10; int tkey)
> A table D (int da; int db),
>
> And I have the following query
> update T set t1 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da =
> <count>) as b where tkey = <value>;
> update T set t2 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da =
> <count>) as b where tkey = <value>;
> ...
> update T set t10 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da
> = <count>) as b where tkey = <value>;
>
> The queries are run on the same <value>. Is there anyway to optimize
> this???
>
>
> Thanks
> Wei
>
>
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2009-03-18 08:16:23 2 left join taking in too many records, 1 join and 1 left join too few was: join
Previous Message Wei Weng 2009-03-17 21:43:39 How do I optimize this?