Received: from relay.freestart.hu (mx.freestart.hu [213.197.64.3]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f45DiTA64400 for ; Sat, 5 May 2001 09:44:29 -0400 (EDT) (envelope-from pgerzson@freestart.hu) Received: from jaguar (line-71-70.dial.freestart.hu [213.197.71.70]) by relay.freestart.hu (Postfix) with SMTP id 436902E09; Sat, 5 May 2001 15:44:39 +0200 (MET DST) Message-ID: <01b001c0d569$b3513560$4647c5d5@jaguar> From: "Gyozo Papp" To: "Jesus Aneiros" Cc: References: Subject: Re: psql with PHP question Date: Sat, 5 May 2001 15:45:51 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id f45DiXA64430 X-Archive-Number: 200105/22 X-Sequence-Number: 331 Hello, just some more word : > > In my opinion, these queries make the same : > > SELECT id FROM article WHERE id=(SELECT MAX(id) FROM article); > > SELECT MAX(id) FROM article; > > > > but the latter one is much more simple and you do not overload your pg. > > (by the way, I think id = (SELECT ...) isn't handled gracefully.) > > Hi, although I agreee with the first part: the subselect is redundat in > this case, I don't understand de second one. The subselect will return one > value, or am I wrong? So, I think the operator = will be correct, or not? I mean the second sentence that I don't think the planner/optimizer is so clever to reduce the former query to the latter one. You're right the sublselect will return one value, but as far as I know this value should be interpreted as a set of one value (because of the select).