Re: report generation from table. - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: report generation from table.
Date
Msg-id 20091021121607.GA1086@a-kretschmer.de
Whole thread Raw
In response to report generation from table.  (sathiya psql <sathiya.psql@gmail.com>)
Responses Re: report generation from table.  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-sql
In response to sathiya psql :
> Hi All,
> 
> I have been searching for, Preparing report from a huge table.
> 
> Queries am executing now are,
> SELECT count(*) from HUGE_TBL where cond1, cond2;
> SELECT count(*) from HUGE_TBL where cond1, cond3;
> --- like this i have different conditions(10-15 different things ) and
> different amount of conditions ( 2 - 5 condition ).
> 
> As that is a very huge table, it took time to execute each query ( 2 min ). And
> finally it takes 15 times that ( 30 min ).  Is there anyway to do the above
> report efficiently ?
> 
> Such executing the query only once, and getting all different outputs required
> ? or fetching result from some cache ?

select sum(case when <cond1> and <cond2> then 1 else 0 end) as query1,
sum(case when <cond1> and <cond3> then 1 else 0 end) as query2, ... from
table;


It forces a whole seq. scan, but only once.


Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)


pgsql-sql by date:

Previous
From: sathiya psql
Date:
Subject: report generation from table.
Next
From: Rob Sargent
Date:
Subject: Re: report generation from table.