Re: Problem query - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Problem query
Date
Msg-id 4DE770E6020000250003E01C@gw.wicourts.gov
Whole thread Raw
In response to Re: Problem query  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: Problem query  (Shaun Thomas <sthomas@peak6.com>)
List pgsql-performance
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:
> Shaun Thomas <sthomas@peak6.com> wrote:

>> What you really want is this:
>>
>> SELECT count(1) FROM (
>>    SELECT DISTINCT tds_cx_ind, cxs_ind_2
>>      FROM max_xtrv_st_t
>> );
>
> Or maybe:
>
> SELECT count(DISTINCT (tds_cx_ind, cxs_ind_2)) FROM max_xtrv_st_t;

Or maybe not.  I tried various forms of the query against "real"
tables here, and Shaun's format was ten times as fast as my last
suggestion and 12% faster than my first suggestion.

They all gave the same result, of course, and they all used a seq
scan..

-Kevin

pgsql-performance by date:

Previous
From: Shaun Thomas
Date:
Subject: Re: Problem query
Next
From: Shaun Thomas
Date:
Subject: Re: Problem query