Received: from relay.freestart.hu (mx.freestart.hu [213.197.64.3]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f43GHrA98781; Thu, 3 May 2001 12:17:54 -0400 (EDT) (envelope-from pgerzson@freestart.hu) Received: from jaguar (line-69-81.dial.freestart.hu [213.197.69.81]) by relay.freestart.hu (Postfix) with SMTP id C21FF2E12; Thu, 3 May 2001 18:18:05 +0200 (MET DST) Message-ID: <011301c0d3ec$cd91c940$5145c5d5@jaguar> From: "Gyozo Papp" To: "Jason" , Cc: , References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> Subject: Re: [PHP] psql with PHP question Date: Thu, 3 May 2001 18:19:10 +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 f43GHxC98786 X-Archive-Number: 200105/102 X-Sequence-Number: 8747 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.) ----- Original Message ----- From: "Jason" To: Cc: ; Sent: 2001. május 3. 14:06 Subject: [PHP] psql with PHP question > Hi, I want to try and optimize my calls to postgreSQL from PHP. If > I only need one field from a select statement, what should I use? I am > currently using: > $q = pg_Exec("SELECT id FROM article WHERE id=(SELECT MAX(id) > FROM article)"); > $maxid = pg_fetch_array($q, 0); > echo "The highest id is ". $maxid[0]; > What can I use besides an array to get a single value? In general, using > a single variable always saves more memory than using an array? Thank > you. > Jason > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html