Re: Nested query performance issue

From: Glenn Maynard <glennfmaynard(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Nested query performance issue
Date: 2009-04-08 21:54:55
Message-ID: d18085b50904081454q73260e6ai5f71b1e89e57208f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

(I didn't notice that I ended up with "score.score" in this test case. Oops.)

2009/4/8 Віталій Тимчишин <tivv00(at)gmail(dot)com>:
> How about
>
> select s1.*
> from score s1 join score s2 on s1.game_id=s2.game_id and s2.score >=
> s1.score
> group by s1.*
> having count(s2.*) <= N

I can see what this is doing, but I'm getting:

ERROR: could not identify an ordering operator for type score
HINT: Use an explicit ordering operator or modify the query.

I'm not sure why; if I replace s1.* and s2.* with s1.id and s2.id it
works, but then I only get IDs.

Unfortunately, with N = 1 this takes 8100ms (vs. 950ms and 25ms)...

--
Glenn Maynard

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Rainer Mager 2009-04-08 22:49:39 Re: difficulties with time based queries
Previous Message Віталій Тимчишин 2009-04-08 21:30:48 Re: Nested query performance issue