473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Browsing through a table

Hello all you Gurus.

I'm trying to find out how to fetch sequential blocks of data from a
table in a most efficient way.

Let's suppose the following:
I have a reasonably large table (say 1Milion records) containing part
information (parts of machinery (eg. the SPJ database from C.J. Date :P)
) placed in a DB2 database (stinger).

I have a client which uses a grid to browse through the data.
Let's say I want to use the grid to browse through all the parts stored
in that table (don't ask why I just wanna). Obviously I don't want to
send the entire table to the client, so I want to browse through the
data using blocks (lets say each of 100 records).

When I reach the end of one block the other block should be loaded and
displayed.

During the day data is stored in the database.
The primary key is a part number.

One way to do this is by selecting the first (blocknr * 100) rows,
reverse sort it and then select the first 100 rows of that resultset.
using this method on a rather large table can be painful, especially
when you get to the blocks near the end of the table.

I'm experimenting with a Multidimensional Table (MDC).
Using a special blocknumber column in the table I can fysically store
the parts in groups of 100 records, but during the administration window
the blocknumbers need to be redistributed (and REORG-ed) to keep the
blocksize near 100.

In short:
I just want to be able to browse through a table using blocks, but I
don't know how to do this in the most efficient way.
Does anyone have any opinion on this.

(BTW, it's not my idea to browse through a huge table, and I really
don't want to, but since it is not my descision to make.)

-R-
Nov 12 '05 #1
4 1396
Jurgen Haan wrote:
Hello all you Gurus.

I'm trying to find out how to fetch sequential blocks of data from a
table in a most efficient way.

Let's suppose the following:
I have a reasonably large table (say 1Milion records) containing part
information (parts of machinery (eg. the SPJ database from C.J. Date :P)
) placed in a DB2 database (stinger).

I have a client which uses a grid to browse through the data.
Let's say I want to use the grid to browse through all the parts stored
in that table (don't ask why I just wanna). Obviously I don't want to
send the entire table to the client, so I want to browse through the
data using blocks (lets say each of 100 records).

When I reach the end of one block the other block should be loaded and
displayed.

During the day data is stored in the database.
The primary key is a part number.

One way to do this is by selecting the first (blocknr * 100) rows,
reverse sort it and then select the first 100 rows of that resultset.
using this method on a rather large table can be painful, especially
when you get to the blocks near the end of the table.

I'm experimenting with a Multidimensional Table (MDC).
Using a special blocknumber column in the table I can fysically store
the parts in groups of 100 records, but during the administration window
the blocknumbers need to be redistributed (and REORG-ed) to keep the
blocksize near 100.

In short:
I just want to be able to browse through a table using blocks, but I
don't know how to do this in the most efficient way.
Does anyone have any opinion on this.

(BTW, it's not my idea to browse through a huge table, and I really
don't want to, but since it is not my descision to make.)

You can use a scrollable cursor. This feature is supported through
various client interfaces such as JDBC and CLI.
The scrollable cursor will handle the metadata of the numbering and
bookmarking internally. No need to update your fact able.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Serge Rielau wrote:
You can use a scrollable cursor. This feature is supported through
various client interfaces such as JDBC and CLI.
The scrollable cursor will handle the metadata of the numbering and
bookmarking internally. No need to update your fact able.

Cheers
Serge


We're using a custom application using the DB2 development client libs.
these libs have a function in the API for using a scrollable cursor?
Didn't know something like that existed. Very nice.

Thank you
-R-
Nov 12 '05 #3
Serge Rielau wrote:
You can use a scrollable cursor. This feature is supported through
various client interfaces such as JDBC and CLI.
The scrollable cursor will handle the metadata of the numbering and
bookmarking internally. No need to update your fact able.

Cheers
Serge


Woops one proble though.
We're using thin clients connecting to loadbalanced application servers
which connect to the database. Because of the fact that the a call can
be directed to any application server, the calls are stateless. (each
call is a seperate connection with its own cursor)

So it has to be done in a higher level.

Is it possible to place a cursor on a given position? (guess not).
And lets say I cannot influence the cursor anymore, the only thing I can
do is write some fancy SQL and change some of the algorithms used by the
grid. In that situation, is there anything I can do to improve
performance over the "select first(100) from (select first(blocknumber *
100) * from very_large_table order by PK descending)".

-R-
Nov 12 '05 #4
Jurgen Haan wrote:
Serge Rielau wrote:
You can use a scrollable cursor. This feature is supported through
various client interfaces such as JDBC and CLI.
The scrollable cursor will handle the metadata of the numbering and
bookmarking internally. No need to update your fact able.

Cheers
Serge

Woops one proble though.
We're using thin clients connecting to loadbalanced application servers
which connect to the database. Because of the fact that the a call can
be directed to any application server, the calls are stateless. (each
call is a seperate connection with its own cursor)

So it has to be done in a higher level.

Is it possible to place a cursor on a given position? (guess not).
And lets say I cannot influence the cursor anymore, the only thing I can
do is write some fancy SQL and change some of the algorithms used by the
grid. In that situation, is there anything I can do to improve
performance over the "select first(100) from (select first(blocknumber *
100) * from very_large_table order by PK descending)".

-R-

OK if you order by PK this is easy:
SELECT pk, ... FTOM table WHERE pk > ?
ORDER BY pk FETCH FIRST 100 ROWS ONLY

Start of with ? being some less than minimum values (like -1, or '')
Then for subsequent calls just feed in the last pk fetched.
The primary key index will get you quickly to the start and
FETCH FIRST 100 ROWS will ensure you get "early out".

Things would be more messy with an arbitrary order...

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: redneck_kiwi | last post by:
Need some opinions on how best to display in excess of 14K records based on users search criteria. Application Concept: ----------------------- User enters various search criteria (as many...
10
by: Paul Kooistra | last post by:
I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. ...
26
by: Dan Nash | last post by:
Hi guys I have a page that is *supposed* to list the directories on the server. Here's the code... folderspec = server.MapPath("./images/") set fso =...
0
by: Alan Cobb | last post by:
Hi, I have a VS2003 solution that includes CSharp (CS), managed C++ (MCPP) and unmanaged C++ (UMCPP) projects. It's unclear to me how integrated the source browsing is supposed to be for all...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
4
by: Hemant Shah | last post by:
Folks, Our client has a program that browses whole table from begining to end. The table has 1 million rows in it. REORGCHK does not show any problems. It has unique index defined on KEY0...
2
by: Joe Kovac | last post by:
Hi! I have a Web Site, where I turned directory browsing off. I want only one sub folder to be browsable: e.g. MyApp/Files/... How do I do that? Any setting in the web.config? Thanks Joe
1
by: martens | last post by:
Hi everybody, got the problem that one of my users cannot browse through the data of my database. He only sees 1/1. But I can browse through it seeing 1/457. So does somebody know if there is a...
3
by: Dan99 | last post by:
I am not sure if I should post this here or in a potgre group, but I will start here. I recently got a new server and thus when I copied all the files to the new machine, I logically decided to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.