Re: Speed comparison to Oracle. Why was this query slower

From: Francisco Reyes <lists(at)natserv(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Speed comparison to Oracle. Why was this query slower
Date: 2002-02-23 03:30:35
Message-ID: 20020222222546.C87438-100000@zoraida.natserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 22 Feb 2002, Bruce Momjian wrote:

> Tom Lane wrote:
> > Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> > > On Fri, Feb 22, 2002 at 05:23:40PM -0500, Francisco Reyes wrote:
> > >>> Is Oracle better at aggregate functions?
> > >> How could it be done in a more clever fashion?
> >
> > > By hashing. Get a hash table. For each row, hash the grouping rows to lookup
> > > the intermediate aggregate stage to aggregate this row into. At the end, run
> > > through your hash dumping the results.
>
> Was the original users doing GROUP BY with the aggregate? I don't
> remember.

I started the thread. Not sure if you refered to me when you wrote about
the "original user".

If so my query was something along the lines:
select field1, count(*) from mytable group by field1;

The table is 770K records and the result took 15 seconds on PostgreSQL. It
only took 10 seconds on Oracle. The Oracle table had 730K rows.

Other queries which would do also a sequential scan, but with a smaller
result set was faster on Postgresql. About 2 seconds on Postgresql and 3
to 4 seconds on Oracle. That other query was:
select field1, count(*) from mytable group by field1 where value between
val1 and val2;

The second query operated on a set of a couple of thousand records.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2002-02-23 03:31:53 Re: game db
Previous Message Peter Lacey 2002-02-23 03:13:58 Re: PostgreSQL GUI?