pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Arbash Meinel <john@arbash-meinel.com>
To: Steinar H. Gunderson <sgunderson@bigfoot.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance pb vs SQLServer.
Date: Sun, 14 Aug 2005 20:05:58 -0500
Message-ID: <42FFEA76.6070109@arbash-meinel.com> (raw)
In-Reply-To: <20050815010159.GA27795@uio.no>
References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr>
	<42FFE17A.6010208@arbash-meinel.com>
	<20050815010159.GA27795@uio.no>

Steinar H. Gunderson wrote:

>On Sun, Aug 14, 2005 at 07:27:38PM -0500, John Arbash Meinel wrote:
>  
>
>>My guess is that this is part of a larger query. There isn't really much
>>you can do. If you want all 3.2M rows, then you have to wait for them to
>>be pulled in.
>>    
>>
>
>To me, it looks like he'll get 88 rows, not 3.2M. Surely we must be able to
>do something better than a full sequential scan in this case?
>
>test=# create table foo ( bar char(4) );
>CREATE TABLE
>test=# insert into foo values ('0000');
>INSERT 24773320 1
>test=# insert into foo values ('0000');
>INSERT 24773321 1
>test=# insert into foo values ('1111');
>INSERT 24773322 1
>test=# select * from foo group by bar;
> bar  
>------
> 1111
> 0000
>(2 rows)
>
>I considered doing some odd magic with generate_series() and subqueries with
>LIMIT 1, but it was a bit too weird in the end :-)
>
>/* Steinar */
>  
>
I think a plain "GROUP BY" is not smart enough to detect it doesn't need
all rows (since it is generally used because you want to get aggregate
values of other columns).
I think you would want something like SELECT DISTINCT, possibly with an
ORDER BY rather than a GROUP BY (which was my final suggestion).

John
=:->

Attachments:

  signature.asc (application/pgp-signature, 255B) download

view thread (16+ messages)  latest in thread

Message-ID: <42FFEA76.6070109@arbash-meinel.com>
Permalink:  ../42FFEA76.6070109@arbash-meinel.com/
Also on:    postgresql.org/message-id/42FFEA76.6070109@arbash-meinel.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@arbash-meinel.com, sgunderson@bigfoot.com
  Subject: Re: Performance pb vs SQLServer.
  In-Reply-To: <42FFEA76.6070109@arbash-meinel.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox