Re: Nested query performance issue - Mailing list pgsql-performance

From Glenn Maynard
Subject Re: Nested query performance issue
Date
Msg-id d18085b50904081454q73260e6ai5f71b1e89e57208f@mail.gmail.com
Whole thread Raw
In response to Re: Nested query performance issue  (Віталій Тимчишин <tivv00@gmail.com>)
Responses Re: Nested query performance issue  (Віталій Тимчишин <tivv00@gmail.com>)
List pgsql-performance
(I didn't notice that I ended up with "score.score" in this test case.  Oops.)

2009/4/8 Віталій Тимчишин <tivv00@gmail.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

pgsql-performance by date:

Previous
From: Віталій Тимчишин
Date:
Subject: Re: Nested query performance issue
Next
From: "Rainer Mager"
Date:
Subject: Re: difficulties with time based queries