473,465 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Tree Node Rename Performance Problem

Hi All,
Here I am facing a performance problem with the TreeView Node renaming.

I am displaying a hierarchy Data in a treeview in my Windows C# Application.
My tree view represents an hierarchical view of Parent Nodes and projects where in a projectnode can be added to any ParentNode and hence we may have a project node added to 100 Parent nodes.

In this one, I have an operation of Renaming a Project Node. So whenever I am doing the operation of renaimg a particular Project Node, I need to rename all the instances of the particular node in the whole Tree View.

So each Tree Node is attached a tag ProjectNode
For this one, I am having a collection of ProjectNode and whenever a project node is renamed, I am calling the rename function of ProjectNode which in turn renames the name of the ProjectNode and then throws an event which will be captured again in the Tree View.
In this Event handler, I am searching the whole Tree view by parsing each and every node and renaming it if it matches wiht the ProjectNode.

This operation is taking a long time and causing an performance issue.

Is there any other alternative Dersign pattern aavilable to solve my problem?

-SARADHI
Nov 16 '05 #1
3 6038
Hello!

First of all - are you persisting changes to the datastore (DB) for each and
every node? If this is the case, the wrapping all the changes in a single
Sql statement (embedded within a Sql transaction) could dramatically
increase the performance of your application.

It all depends on what you're doing .. or need to do. Iterating recursively
on a tree structure shouldn't cause a performance issue, unless we're
talking a very large amount of nodes. How many nodes are affected by a
rename operation?
In this one, I have an operation of Renaming a Project Node. So whenever I am doing the operation of renaimg a particular Project Node, I need to rename all the instances of the particular node in the whole Tree View.
Another thing .. you write you're updating all instances of a node in the
tree. Why is this necessary? When adding a node to the tree (i.e. adding a
project node to a parent node), you should only be adding a reference to the
node, not a copy of the node itself (causing redundance and perhaps why you
needed to introduce the event behaviour in the first place).
In this Event handler, I am searching the whole Tree view by parsing each and every node and renaming it if it matches wiht the ProjectNode.


Definately not a good idea. Please see below .. (for instance: think of an
outside hashtable that contains your Project nodes. The tree nodes point to
these unique instances - use a hashtable if you need a single storage for
fast access of each node)

Parent Node
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)

... instead of ..

Parent Node
Project Node A (instance data)
Project Node A (instance data)
Project Node A (instance data)

More info needed.

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #2
Hi anders borum,

I think you misunderstood my points.
I have two objects here ProjectNode , my business obejct and TreeNode a TreeNode of the TreeView in C#.

Whenever I add a ProjectNode to a parentNode, I am creating a TreeNode and attaching a ProjectNode Object as a tag to that one. So wherever this TreeNode is added to the TreeView, the same ProjectNode will be added as a tag.

So Now whenver I renames the TreeNode in the treview AfterSelect event, I am calling the Rename method of the Corresponding ProjectNode Business object and it first renames the Name in the ProjectNode and then fires an event which will be captured in the TreeView. So in turn, the Rename operation will be done only once in the ProjectNode. But since this Project Node is attached as a tag to a lot of TreeNodes, I am parsing through the Whole TReeView and Renaming them in the Display of the TreeView. This Rename operation is nothing to do with the DB operation which is already finished. This renaming of the all the TreeNodes in the TreeView is necessary because you need to show the changes in the ProjectNode business change graphically in the Entire TreeView.

The problem is that the entire TreeView is getting refreshed unnecessarly even if I have to rename only 5 to 6 tree nodes. Since my hierarchy treeview consists of minimum 5000 Nodes, this refreshing operation looks uglier.

Hope you understood my point here.

With Regards,
-SARADHI

"Anders Borum" <an****@sphereworks.dk> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hello!

First of all - are you persisting changes to the datastore (DB) for each and
every node? If this is the case, the wrapping all the changes in a single
Sql statement (embedded within a Sql transaction) could dramatically
increase the performance of your application.

It all depends on what you're doing .. or need to do. Iterating recursively
on a tree structure shouldn't cause a performance issue, unless we're
talking a very large amount of nodes. How many nodes are affected by a
rename operation?
In this one, I have an operation of Renaming a Project Node. So whenever I am doing the operation of renaimg a particular Project Node, I need to rename all the instances of the particular node in the whole Tree View.
Another thing .. you write you're updating all instances of a node in the
tree. Why is this necessary? When adding a node to the tree (i.e. adding a
project node to a parent node), you should only be adding a reference to the
node, not a copy of the node itself (causing redundance and perhaps why you
needed to introduce the event behaviour in the first place).
In this Event handler, I am searching the whole Tree view by parsing each and every node and renaming it if it matches wiht the ProjectNode.


Definately not a good idea. Please see below .. (for instance: think of an
outside hashtable that contains your Project nodes. The tree nodes point to
these unique instances - use a hashtable if you need a single storage for
fast access of each node)

Parent Node
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)

.. instead of ..

Parent Node
Project Node A (instance data)
Project Node A (instance data)
Project Node A (instance data)

More info needed.

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #3
> The problem is that the entire TreeView is getting refreshed unnecessarly
even if I have
to rename only 5 to 6 tree nodes. Since my hierarchy treeview consists of minimum 5000 Nodes, this refreshing operation looks uglier.


I think I'm with you (..). Instead of going through the entire TreeView
whenever a ProjectNode is added, I would create an index on the ProjectNode
with a list of the TreeNodes that this ProjectNode has been added to.

This should shorted the time required to update the tree. Going through each
and every TreeNode is not a good idea as the time required is proportional
to the number of nodes in the tree (which gets worse and worse as the tree
grows, regardless of the ProjectNode being added to 1 or N tree nodes).

Hopefully this will get you started in the right direction..

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #4

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

Similar topics

12
by: pillepop2003 | last post by:
Hey! Can anyone give me a hint, how this problem is best implemented: I have a table of users (see below), where every user has one "superior user" (= parent node), this should be a fully...
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
25
by: prabhat143 | last post by:
Hi, Given a singly linked, null terminated list, how can it be converted to tree? Each node in the list has three attributes: it's ID, it's parent ID and of course, the next node it's pointing...
6
by: sathyashrayan | last post by:
#include<stdio.h> #include<stdlib.h> #include<string.h> struct tree { int data; struct tree *left,*right; }; void init(struct tree *node)
22
by: delraydog | last post by:
It's quite simple to walk to the DOM tree going forward however I can't figure out a nice clean way to walk the DOM tree in reverse. Checking previousSibling is not sufficient as the...
4
by: whitehatmiracle | last post by:
Hello I have written a program for a binary tree. On compiling one has to first chose option 1 and then delete or search. Im having some trouble with the balancing function. It seems to be going...
6
by: Gordon | last post by:
I've developed a CMS that manages content across several sites. The content is represented in a tree structure maintained in a database, where each item has an id and a parent that points to the...
1
by: happy.john1234 | last post by:
Hi, i am a new bie in programming.I am currently doing a project that displays certain hierarchial set of data in tree view.I currently implemented this tree view to be displayed in xml file ...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.