Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Avoid dw_1.RowCount()

153 views
Skip to first unread message

Thorsten Kummer

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to
Hi folks,

is there a faster way to get the number of rows in the primary buffer of
a dw?
Do I have to use dw_1.RowCount() or is there a dw object property that I
can access?

Thanks in advance!
Thorsten


Ron Gallagher

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to
The return code from the Retrieve method is another way of getting the
number of rows.

HTH

Ron Gallagher, CPDP
Atlanta, GA
rongal...@mindspring.com

Thorsten Kummer wrote in message <37D663AC...@planet.de>...

Philip Salgannik

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to

Thorsten Kummer <Kum...@planet.de> wrote in message
news:37D663AC...@planet.de...

> Hi folks,
>
> is there a faster way to get the number of rows in the primary buffer of
> a dw?
> Do I have to use dw_1.RowCount() or is there a dw object property that I
> can access?

Why?


Bruce Armstrong [TeamSybase]

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to
dw_x.RowCount is pretty much the main method. You could do something like
set the value of an instance variable in a datawindow user object to the
result of the rowcount argument to the retrieveend event. However, it
wouldn't be updated (or you would have to update it) to account for filtering,
deletes, etc. All in all, RowCount is the best method. It's also not
particularly slow (that I've seen). Have you had a problem with it?

On Wed, 08 Sep 1999 15:25:00 +0200,
in powersoft.public.powerbuilder.datawindow


Thorsten Kummer <Kum...@planet.de> wrote:
>Hi folks,
>
>is there a faster way to get the number of rows in the primary buffer of
>a dw?
>Do I have to use dw_1.RowCount() or is there a dw object property that I
>can access?
>

>Thanks in advance!
>Thorsten
>

---
Bruce Armstrong [TeamSybase] | Romac/Source International
mailto:Bruce.A...@teamsybase.com | http://www.kforce.com
| http://www.romac-source.com

Preach the gospel at all times. If necessary, use words. [Francis of Assisi]
http://www.kidbrothers.org http://www.fccwc.org
http://www.harvest.org/text/knowgod.html

-----------== Posted via the PFCGuide Web Newsreader ==----------
http://www.pfcguide.com/_newsgroups/group_list.asp

Simon Caldwell

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to
No. What's wrong with using RowCount() anyway? If it's that slow, you've
probably got too many records in your dw.

Simon

Thorsten Kummer wrote in message <37D663AC...@planet.de>...

Ronald Miller

unread,
Sep 8, 1999, 3:00:00 AM9/8/99
to
Hi

You can use the SQLNROWS property of the transaction object (ex:
SQLCA.SQLNROWS) to get the number of rows retrieved. Also, the method
RETRIEVE() of a datawindows returns the number of rows read.

Good luck

Ron.


Thorsten Kummer a écrit dans le message <37D663AC...@planet.de>...

Thorsten Kummer

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
No Bruce, I didn't really have a problem with it. Let me tell you what's going on:

I have to implement a recursive treeview object which reads a table once into a
datastore and then processes the rows.
Each row contains a column with the reference to it's parent row, so implementing
the tree is very easy using a recursive function call.
I encountered very strange performance disadvantages, so I replaced all datawindow
function calls (GetItemNumber() and so on)
by statements that refer to the dw object in dot notation (value =
dw_1.Object.colimn[i]). The RowCount(),SetFilter() and Filter() calls are the only
ones that I'm using.
When processing 1000 rows performance is strong (2 seconds), but with 4000 rows my
computer (PII, 400 MHz) needs more than
40 seconds. Does it have something to do with the recursive call?

"Bruce Armstrong [TeamSybase]" schrieb:

> dw_x.RowCount is pretty much the main method. You could do something like
> set the value of an instance variable in a datawindow user object to the
> result of the rowcount argument to the retrieveend event. However, it
> wouldn't be updated (or you would have to update it) to account for filtering,
> deletes, etc. All in all, RowCount is the best method. It's also not
> particularly slow (that I've seen). Have you had a problem with it?
>
> On Wed, 08 Sep 1999 15:25:00 +0200,
> in powersoft.public.powerbuilder.datawindow
> Thorsten Kummer <Kum...@planet.de> wrote:

> >Hi folks,
> >
> >is there a faster way to get the number of rows in the primary buffer of
> >a dw?
> >Do I have to use dw_1.RowCount() or is there a dw object property that I
> >can access?
> >
> >Thanks in advance!
> >Thorsten
> >
>

Simon Caldwell

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
That surprises me. Using dot notation to refer to a single row/column is
normally *significantly* slower than the equivalent using Get/SetItem. We
have changed parts of our application to remove the dot notation and this
has resulted in major performance improvements.

Are you doing something like
for i=1 to dw_1.RowCount()
// stuff
next

if so, replace with
li_max = dw_1.RowCount()
for i=1 to li_max
// stuff
next

HTH

Simon

Thorsten Kummer wrote in message <37D75726...@planet.de>...

Ron Gallagher

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
Thorsten --

The recursive nature of the call 'may' be the cause of your problem.
However, I'd like to suggest a few alternatives:

1) Since you're using recursive logic, then you really only need to retrieve
the row count once. After retrieving it, store it in an instance variable
and just refer to that instance variable, instead of calling the RowCount()
method. Of course, if you're filtering the records, this won't work.

2) When you load the tree view, are you loading all levels of the tree view
or just the root level? If you're loading all levels, you may want to
rethink this. It's better to just load the root level initially, and then
load lower levels when the parent object expands for the first time. Your
initial load will run much faster, and you won't be loading data into the
tree view that the user never accesses.

3) Another thing to consider is the sorting within the treeview. If you can
properly sort the records in your datastore, then I'd recommend that you
turn off sorting within the treeview. Sorting records in the datastore is
much faster. Once you sort the records in the datastore, use the
InsertItemLast method to add items to the treeview. They will appear in the
order in which you add them.

HTH

Ron Gallagher, CPDP
Atlanta, GA
rongal...@mindspring.com

Thorsten Kummer wrote in message <37D75726...@planet.de>...

Thorsten Kummer

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
Ron, let me first of all thank you for your detailed answer.
1. You're right, though I'm retrieving the data once from the database, I got
dynamic rowcount() values because I'm filtering the
datastore for every 'parent' row (to get the childs of it).
2. I'm loading all levels at one retrieve() because I assume that I cannot use
the PFC built in functionality for recursive trees. Is that right?
There's no fixed structure inside the tree, the user can setup the levels as
deep as needs them and that's why I used the recursive stuff.
I would be glad if I could use the PFC treeview levelservice.
See my table structure:
id number // the unique identifier
label varchar2 // the label to be displayed
parent_id number // the id of the parent treeviewitem

Or is there a way for the PFC service to handle this better than me???

3. The sorted property of the treeview m u s t be set to FALSE, otherwise
performance is decreasing rapidly!
I rather sort the datastore , process the treeview an set the sorted
property to true after all. This treeview sorting is very fast.

4. To Simon Caldwell:
Thank you for your tip! Dot notation speeded up my processing, however ...
Best regards
Thorsten

Ron Gallagher schrieb:

Paul Horan

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
Thorsten,
Just an FYI.. I can highly recommend a book on implementing recursive tree
structures in SQL. It's by David Rozenshtein, and it's entitled 'Tree and
Graph Processing in SQL'. You can get it from SQL Forum Press, at
www.sqlforum.com.
He has an algorithm for a breadth-first traversal of a tree that is orders
of magnitude faster than using recursion in a depth-first approach.

Paul Horan
VCI
Springfield, MA

Thorsten Kummer <Kum...@planet.de> wrote in message

news:37D7BC48...@planet.de...

Bruce Armstrong [TeamSybase]

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
I ran into something similar when I first attempted to create an 'explorer'
object using u_tv and u_lv in PFC. When I first did it against a test database
with 1000 records in a node, it worked fairly well. When I moved over to the
production database with up to 10000 records in a node, it slowed to a crawl.
In my case, the problem is that the listview can't directly accept a datawindow,
so what u_lv does is loops through the rows and columns one at a time and does
a GetItemXXXX on it. Assuming that I've got 20 columns that I want to display
in the listview, and that it takes 1 millisecond (0.001 seconds) for PB to
transfer the data for a single row/column cell, it would still take a minute
and a half (or so) to do that for 4000 rows. I ended up just using a datawindow
rather than u_lv for the right side of the explorer.

Does this sound familiar at all? In any event, you may want to do embed some
timing test to determine specifically where the problem may be coming from.
FWIW, the CPU function is real handy for doing that.

On Thu, 09 Sep 1999 08:43:50 +0200,


in powersoft.public.powerbuilder.datawindow
Thorsten Kummer <Kum...@planet.de> wrote:
>No Bruce, I didn't really have a problem with it. Let me tell you what's going
on:
>
>I have to implement a recursive treeview object which reads a table once into a
>datastore and then processes the rows.
>Each row contains a column with the reference to it's parent row, so
implementing
>the tree is very easy using a recursive function call.
>I encountered very strange performance disadvantages, so I replaced all
datawindow
>function calls (GetItemNumber() and so on)
>by statements that refer to the dw object in dot notation (value =
>dw_1.Object.colimn[i]). The RowCount(),SetFilter() and Filter() calls are the
only
>ones that I'm using.
>When processing 1000 rows performance is strong (2 seconds), but with 4000 rows
my
>computer (PII, 400 MHz) needs more than
>40 seconds. Does it have something to do with the recursive call?
>

---


Bruce Armstrong [TeamSybase] | Romac/Source International
mailto:Bruce.A...@teamsybase.com | http://www.kforce.com
| http://www.romac-source.com

Preach the gospel at all times. If necessary, use words. [Francis of Assisi]
http://www.kidbrothers.org http://www.fccwc.org

http://www.harvest.org/knowgod/index.htm

Mark Hill

unread,
Sep 10, 1999, 3:00:00 AM9/10/99
to
Another option may be to only populate the tree when expanding a node using
the expanded event and the expanded-once attribute. That may remove
performance issues altogether, depending on the depth of your tree.

Just an idea.

Mark Hill
mh...@lims.com

Ron Gallagher <rongal...@mindspring.com> wrote in message
news:B1Er6tr##GA....@forums.sybase.com...

> >No Bruce, I didn't really have a problem with it. Let me tell you what's
> going on:
> >
> >I have to implement a recursive treeview object which reads a table once
> into a
> >datastore and then processes the rows.
> >Each row contains a column with the reference to it's parent row, so
> implementing
> >the tree is very easy using a recursive function call.
> >I encountered very strange performance disadvantages, so I replaced all
> datawindow
> >function calls (GetItemNumber() and so on)
> >by statements that refer to the dw object in dot notation (value =
> >dw_1.Object.colimn[i]). The RowCount(),SetFilter() and Filter() calls are
> the only
> >ones that I'm using.
> >When processing 1000 rows performance is strong (2 seconds), but with
4000
> rows my
> >computer (PII, 400 MHz) needs more than
> >40 seconds. Does it have something to do with the recursive call?
> >

> >"Bruce Armstrong [TeamSybase]" schrieb:
> >
> >> dw_x.RowCount is pretty much the main method. You could do something
> like
> >> set the value of an instance variable in a datawindow user object to
the
> >> result of the rowcount argument to the retrieveend event. However, it
> >> wouldn't be updated (or you would have to update it) to account for
> filtering,
> >> deletes, etc. All in all, RowCount is the best method. It's also not
> >> particularly slow (that I've seen). Have you had a problem with it?
> >>

> >> On Wed, 08 Sep 1999 15:25:00 +0200,


> >> in powersoft.public.powerbuilder.datawindow
> >> Thorsten Kummer <Kum...@planet.de> wrote:

> >> >Hi folks,
> >> >
> >> >is there a faster way to get the number of rows in the primary buffer
of
> >> >a dw?
> >> >Do I have to use dw_1.RowCount() or is there a dw object property that
I
> >> >can access?
> >> >
> >> >Thanks in advance!
> >> >Thorsten
> >> >
> >>

> >> ---
> >> Bruce Armstrong [TeamSybase] | Romac/Source International
> >> mailto:Bruce.A...@teamsybase.com | http://www.kforce.com
> >> | http://www.romac-source.com
> >>
> >> Preach the gospel at all times. If necessary, use words. [Francis of
> Assisi]
> >> http://www.kidbrothers.org http://www.fccwc.org

> >> http://www.harvest.org/text/knowgod.html

0 new messages