X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EBC75D1B4F6 for ; Thu, 2 Oct 2003 18:51:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53753-06 for ; Thu, 2 Oct 2003 15:50:37 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id A09D5D1B4EA for ; Thu, 2 Oct 2003 15:50:20 -0300 (ADT) Received: (qmail 26071 invoked from network); 2 Oct 2003 18:50:06 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 2 Oct 2003 18:50:06 -0000 Subject: Re: low cardinality column From: Rod Taylor To: rwu@cbnco.com Cc: Postgresql Performance In-Reply-To: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-w0mXFtaGiVZsl8Aqdhey" Message-Id: <1065120643.89807.40.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 02 Oct 2003 14:50:44 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/56 X-Sequence-Number: 3804 --=-w0mXFtaGiVZsl8Aqdhey Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-10-02 at 14:30, Rong Wu wrote: > Hi, >=20 > I have a select like this: >=20 > SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=3D0; For various reasons (primarily MVCC and the ability to make custom aggregates making it difficult) MAX() is not optimized in this fashion. Try: SELECT transactionid FROM ... WHERE ... ORDER BY transactionid DESC LIMIT 1; --=-w0mXFtaGiVZsl8Aqdhey Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/fHOD6DETLow6vwwRAvQ9AJ93uI6ST8WDbKxNzUHf67xHwAOL6QCfd2y8 vQJfn+GLC/XEjy0+358IQxc= =42Nw -----END PGP SIGNATURE----- --=-w0mXFtaGiVZsl8Aqdhey--