db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <dan...@nuix.com>
Subject Re: How to efficiently check for existence of a row?
Date Mon, 20 Oct 2008 00:30:25 GMT
Amir Michail wrote:
> Hi,
> Given some condition, how do you efficiently check whether there is at
> least one row that satisfies that condition?
> count(*) is slow.

I too wish that count(*) were fast, at least for queries which are only 
using indexes. :-(

What about just doing the query and checking rs.next()?  setMaxRows(1) 
should theoretically speed it up, but I haven't noticed performance 
issues which would justify setting it.


Daniel Noll                            Forensic and eDiscovery Software
Senior Developer                              The world's most advanced
Nuix                                                email data analysis
http://nuix.com/                                and eDiscovery software

View raw message