Re: JDBC: Fast way to find the number of rows in a ResultSet?



On May 25, 3:11 pm, Philipp Taprogge <Philipp.Tapro...@xxxxxxx> wrote:
Hi!

Thus spake Arne Vajhøj on 05/24/2007 01:53 AM:

To do that the ResultSet would likely need to be scrollable
and that will cause many JDBC drivers to read all data
into memory. So this solution works best with small data.

True, but that's a limitation to JDBC. If you can't do a SELECT COUNT(*) far
some reason, then this is AFAICS your only option. Using last() is just
prettier and could be a little bit better performance-wise if the driver is
optimized for it.

Regards,

Phil

The lion's share of the work involved in a driver implementing last()
is simply the reading in (and maybe having to ask for) the data, and
caching it in memory if it's a scrollable result set. A loop of
next() calls won't be any different in performance. And again, if
someone else adds or deletes rows in between your receiving the
results of you "select count(*)" and when you run your actual query
for the data, then you will get a different number of rows than your
count anyway.

Joe Weinstein at BEA Systems

.



Relevant Pages

  • Re: JDBC: Fast way to find the number of rows in a ResultSet?
    ... and that will cause many JDBC drivers to read all data ... into memory. ... but that's a limitation to JDBC. ... prettier and could be a little bit better performance-wise if the driver is ...
    (comp.lang.java.databases)
  • PROBLEM: Memory leak in -test9?
    ... There seems to be a memory leak in 2.6.0-test9. ... 0cf8-0cff: PCI conf1 ... 16 nodes reported by PnP BIOS; 16 recorded by driver ... ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 ...
    (Linux-Kernel)
  • redhat 7.3 installation
    ... Linux agpgart interface v0.99 Jeff Hartmann ... agpgart: Maximum main memory to use for agp memory: 202M ... PCI: PCI BIOS revision 2.10 entry at 0xf0900, ... Serial driver version 5.05c with MANY_PORTS MULTIPORT SHARE_IRQ SERIAL_PCI ISAPNP enabled ...
    (RedHat)
  • PROBLEM REMAINS: [sata_nv ADMA breaks ATAPI] Crash on accessing DVD-RAM
    ... My system has 4G of physical memory, but when I use mem=4096M kernel sees only ... Port Connector Information ... Internal Connector Type: On Board IDE ... Real Time Clock Driver v1.12ac ...
    (Linux-Kernel)
  • Re: blue screen computer shuts down.......
    ... of files, as well as errors in the event viewer, this thing is driving me ... Driver Development Tools: Windows DDK ... A memory access violation occurred. ... If exception code 0x80000003 occurs, ...
    (microsoft.public.windowsxp.help_and_support)