Skip to Content
Java Programming with Oracle SQLJ
book

Java Programming with Oracle SQLJ

by Jason Price
August 2001
Intermediate to advanced
400 pages
9h 28m
English
O'Reilly Media, Inc.
Content preview from Java Programming with Oracle SQLJ

10.1. Row Prefetching

SQL queries sometimes return large numbers of rows. A SQLJ program needs to communicate with the database in order to retrieve those rows. Each communication between a SQLJ program and the database is known as a round trip, and each round trip exacts a cost in terms of time. You can increase performance by reducing the number of round trips required to handle the rows returned by a query. By default, a SQLJ program receives a maximum of 10 rows at a time from the database in each round trip; this is known as prefetching the rows. As you will soon see, the number of rows fetched during each round trip can be changed, allowing a SQLJ program to receive many more rows during each round trip to the database. This can increase performance dramatically when retrieving many rows from a database over a network.

For example, assume that you have a query that returns 10,000 rows from a database running on a remote machine, and that your program receives 10 rows at a time during each round trip. This scenario results in 1,000 round trips across the network. If you modify your program to receive 100 rows during each round trip, the result is only 100 round trips. The fewer the round trips across the network, the faster all the rows are received by the program.

10.1.1. Specifying the Number of Rows to Prefetch

Prefetching is set up for the underlying JDBC connection in a SQLJ connection context. (Connection contexts are described in Chapter 8.) The method called

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java Programming with Oracle JDBC

Java Programming with Oracle JDBC

Donald Bales

Publisher Resources

ISBN: 0596000871Catalog PageErrata