Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 66350 invoked from network); 20 Oct 2008 04:19:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Oct 2008 04:19:12 -0000 Received: (qmail 3505 invoked by uid 500); 20 Oct 2008 04:19:13 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 3477 invoked by uid 500); 20 Oct 2008 04:19:13 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 3466 invoked by uid 99); 20 Oct 2008 04:19:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Oct 2008 21:19:13 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of amichail@gmail.com designates 64.233.178.241 as permitted sender) Received: from [64.233.178.241] (HELO hs-out-0708.google.com) (64.233.178.241) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Oct 2008 04:18:01 +0000 Received: by hs-out-0708.google.com with SMTP id m63so680136hsc.7 for ; Sun, 19 Oct 2008 21:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=GLUawcaxCmJcb2OxRiDXMSksPS/iTc4js6ae8wN7GAk=; b=N1nkkraeWAIGFdZeFcKr5HMxc1P+xfHrY8TIJRWAfL+jEN6fAD86b6r0+ZWkfZyHcO M9mCHZnAptcRwsVv/JcCWYkASyZGMAqRMcgafjLfudWPcCHtDirCmiKD0HI6EuLo9P2l ASWgVoWKk/okBSoOSGpbZCM5ZD9KhQA+/Qrwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=RTVz7i3ZgPo5WT/o1cfzOfcPNSsBoyIC10u8Zd9yIIXmq2/QOTqu8sKtRWVfz2jG/Q s0AEM4HBM7W/MZrAMeMHnuFSBYo3a4ZJnRa/p0NyO/tvJ+uRMIkQLovWnbtv+kWAR8Px I3OKWowGSA937vqxZgWroPfnT2hk+/F/QQWRI= Received: by 10.100.190.14 with SMTP id n14mr7906847anf.19.1224476319039; Sun, 19 Oct 2008 21:18:39 -0700 (PDT) Received: by 10.100.38.9 with HTTP; Sun, 19 Oct 2008 21:18:38 -0700 (PDT) Message-ID: Date: Mon, 20 Oct 2008 00:18:38 -0400 From: "Amir Michail" To: "Derby Discussion" Subject: Re: Most efficient way to get max row id? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4d2670740810191400o6324c288u2d2ecdd1c5ab0457@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Oct 20, 2008 at 12:15 AM, Amir Michail wrote: > On Sun, Oct 19, 2008 at 11:25 PM, Kai Ponte wrote: >> On Sunday 19 October 2008 02:04:29 pm Amir Michail wrote: >>> On Sun, Oct 19, 2008 at 5:00 PM, Peter Ondru=9Aka >>> >>> wrote: >>> > You want to use identity: Defining an identity column >>> >>> Yes, but how do you get the max row id efficiently without adding anoth= er >>> row? >> >> In the particular table, how many rows are you referring to? A few thous= and? A >> few million? A hundred million? >> >> Do you have an index on the identity column? What's your datatype? > > ~60,000 rows But there's also a where in the query, so the number of rows considered by max will vary. A slow case involves ~ 16000 rows. Amir > > So if I put an index on the identity column, max will be fast? > > Amir > >> >> -- >> kai >> www.filesite.org || www.perfectreign.com >> >> >> Clean out a corner of your mind and creativity will instantly fill it. -= Dee >> Hock >> > > > > -- > http://chatbotgame.com > http://numbrosia.com > http://twitter.com/amichail > --=20 http://chatbotgame.com http://numbrosia.com http://twitter.com/amichail