Re: Need SQL Help Finding Current Status of members - Mailing list pgsql-sql

From Alvaro Herrera
Subject Re: Need SQL Help Finding Current Status of members
Date
Msg-id 20051216135732.GA22004@surnet.cl
Whole thread Raw
In response to Re: Need SQL Help Finding Current Status of members  ("Michael Avila" <Michael.Avila.1@sbcglobal.net>)
List pgsql-sql
Michael Avila wrote:
> Interesting. I think I understand that. I have never worked with a SELECT
> within a SELECT (I think that is called a subquery). I am guessing that it
> works its way through the member status records until the latest date
> "floats" to the top (nothing is > than it).
>
> Will that be a problem performance-wise if there are thousands of records?

The actual execution of the query may be something completely different,
depending on what the optimizer decides.  I doubt it will suck much,
because the optimizer is quite good.  Try executing

EXPLAIN query;

to see how it would be executed, and 

EXPLAIN ANALYZE query;

to see the above plus the real numbers that the executor got after
executing it (number of times each loop was executed, time spent at each
execution step, etc).

Read the ANALYZE page to see how are these things supposed to be read.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-sql by date:

Previous
From: "Michael Avila"
Date:
Subject: Re: Need SQL Help Finding Current Status of members
Next
From: "Ken Winter"
Date:
Subject: Rule causes baffling error