Skip site navigation (1) Skip section navigation (2)

Re: [SQL] two queryes in a single tablescan

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: "Stefano Dal Pra" <s(dot)dalpra(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: [SQL] two queryes in a single tablescan
Date: 2007-10-20 10:58:24
Message-ID: 20071020125824.75df357c@kingfisher.sec.intern.logix-tt.com (view raw or flat)
Thread:
Lists: pgsql-performancepgsql-sql
Hi, Stefano,

"Stefano Dal Pra" <s(dot)dalpra(at)gmail(dot)com> wrote:

> suppose you have a large table tab and two (or more) queryes like this:
> 
> SELECT count(*),A FROM tab WHERE C GROUP BY A;
> SELECT count(*),B FROM tab WHERE C GROUP BY B;
> 
> is there any way to get both results in a single query,
> eventually through stored procedure?
> The retrieved [count(*),A] ; [count(*),B)] data couldnt fit
> on a single table, of course.
> 
> The main goal would be to get multiple results while scanning the
> table[s] once only
> thus getting results in a faster  way.

PostgreSQL 8.3 contains great improvements in this area, you can simply
start the selects from concurrent connections, and the backend will
synchronize the scans.



Regards,
Markus

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org

In response to

Responses

pgsql-performance by date

Next:From: Andreas KretschmerDate: 2007-10-20 17:19:39
Subject: Re: [SQL] two queryes in a single tablescan
Previous:From: Scott MarloweDate: 2007-10-19 18:21:26
Subject: Re: how to improve the performance of creating index

pgsql-sql by date

Next:From: Andreas KretschmerDate: 2007-10-20 17:19:39
Subject: Re: [SQL] two queryes in a single tablescan
Previous:From: Scott MarloweDate: 2007-10-20 09:01:20
Subject: Re: backup database tablespace with rsync?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group