pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marko Niinimaki <manzikki@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: slow subselects
Date: Tue, 20 Feb 2007 02:43:06 -0500
Message-ID: <22952.1171957386@sss.pgh.pa.us> (raw)
In-Reply-To: <58b7e6510702192310v77517652q4ba8ecaf50ea161c@mail.gmail.com>
References: <58b7e6510702192302i6b526e56wee847a2122cec3aa@mail.gmail.com>
	<58b7e6510702192310v77517652q4ba8ecaf50ea161c@mail.gmail.com>

"Marko Niinimaki" <manzikki@gmail.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



view thread (4+ messages)  latest in thread

Message-ID: <22952.1171957386@sss.pgh.pa.us>
Permalink:  ../22952.1171957386@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22952.1171957386@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, manzikki@gmail.com
  Subject: Re: slow subselects
  In-Reply-To: <22952.1171957386@sss.pgh.pa.us>

* 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