Skip site navigation (1) Skip section navigation (2)

Re: slow subselects

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marko Niinimaki" <manzikki(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: slow subselects
Date: 2007-02-20 07:43:06
Message-ID: 22952.1171957386@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
"Marko Niinimaki" <manzikki(at)gmail(dot)com> writes:
> I'm having a surprising performance problem with the following simple
> 'highscore report'

> select studentid, (select max(score) from
> studentprofile prof where prof.studentid = students.studentid) from students;

> I have indexes on students(studentid) and studentprofile(studentid).

The optimal index for this would be on studentprofile(studentid,score).
A quick test says that PG 8.1 knows what to do with such an index ---
what does EXPLAIN show for this query?

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Rafa CominoDate: 2007-02-20 10:41:54
Subject: Having performance problems with TSearch2
Previous:From: ismo.tuononenDate: 2007-02-20 07:21:45
Subject: Re: slow subselects

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group