X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 822ED9DCA02 for ; Fri, 16 Dec 2005 09:57:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24961-09 for ; Fri, 16 Dec 2005 09:57:24 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from alvh.no-ip.org (201-221-201-24.bk11-dsl.surnet.cl [201.221.201.24]) by postgresql.org (Postfix) with ESMTP id 407959DC849 for ; Fri, 16 Dec 2005 09:57:18 -0400 (AST) Received: by alvh.no-ip.org (Postfix, from userid 1000) id 4ECA4C2DC71; Fri, 16 Dec 2005 10:57:32 -0300 (CLST) Date: Fri, 16 Dec 2005 10:57:32 -0300 From: Alvaro Herrera To: Michael Avila Cc: SQL PostgreSQL MailList Subject: Re: Need SQL Help Finding Current Status of members Message-ID: <20051216135732.GA22004@surnet.cl> Mail-Followup-To: Michael Avila , SQL PostgreSQL MailList References: <43A29304.9050801@anpe.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.443 required=5 tests=[AWL=-0.476, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.443 X-Spam-Level: * X-Archive-Number: 200512/141 X-Sequence-Number: 23683 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.