Re: Need SQL Help Finding Current Status of members

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Michael Avila <Michael(dot)Avila(dot)1(at)sbcglobal(dot)net>
Cc: SQL PostgreSQL MailList <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Need SQL Help Finding Current Status of members
Date: 2005-12-16 13:57:32
Message-ID: 20051216135732.GA22004@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Farewell 2005-12-16 15:42:34 Problem obtaining MAX values FROM TABLE
Previous Message Michael Avila 2005-12-16 13:46:03 Re: Need SQL Help Finding Current Status of members