From: Marko Niinimaki <manzikki@gmail.com>
To: pgsql-performance@postgresql.org
Subject: slow subselects
Date: Tue, 20 Feb 2007 16:10:55 +0900
Message-ID: <58b7e6510702192310v77517652q4ba8ecaf50ea161c@mail.gmail.com> (raw)
In-Reply-To: <58b7e6510702192302i6b526e56wee847a2122cec3aa@mail.gmail.com>
References: <58b7e6510702192302i6b526e56wee847a2122cec3aa@mail.gmail.com>
Hello,
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).
Row counts: about 160 000 in each students and studentprofile.
Postgres version:
postgresql-8.1.8-1.fc5
postgresql-server-8.1.8-1.fc5
This is a dual-processor 3Ghz 64bit box with 2 GB mem.
Running the query takes 99% CPU and 1% mem.
I have the same data in MSSQL and there the query takes less than a
minute. With postgres it seems to take several hours.
Is there a way of making this faster?
Marko
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: manzikki@gmail.com
Subject: Re: slow subselects
In-Reply-To: <58b7e6510702192310v77517652q4ba8ecaf50ea161c@mail.gmail.com>
* 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