473,385 Members | 1,798 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,385 software developers and data experts.

best way to retrieve thousands of records.

I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.
Nov 21 '05 #1
12 12226
jaYPee wrote:
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).


What on earth are you planning to do with 3000 parent records? No human
on earth can handle that much rows in one go.

I'd redesign your gui with a more user friendlier system. Your current
system requires a human to browse through 3000 rows to find a row to
edit it, pretty harsh / time consuming.

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog : http://weblogs.asp.net/FBouma
Microsoft MVP (C#)
Nov 21 '05 #2
jaYPee,

I assume you want "one" SQL string to get 3 tables.

Where you get from table 1 least say one datarow in a table.
In table 2 the rows from the related key in table 1
in table 3 the rows from the related keys in table 2

Because I don't like (hate) SQL, I think it is better that somebody else
give you this answer.

Or you should like to do it with 3 seperated SQL strings where you can than
create in a for loop your own sql string with a where or clause for the
third table from the second

http://msdn.microsoft.com/library/de...ca-co_2y2h.asp

Just an idea, not great

Cor

"jaYPee" <hi******@yahoo.com>
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.

Nov 21 '05 #3
jayPee,

That new MSDN system creates no links anymore that can be copied or set in
favorits,

So I was searching on "contains" and went than to Or, maybe you can you do
that yourself. (sql Or gives a little bit to much hits)

Cor

..
"Cor Ligthert" <no************@planet.nl>
jaYPee,

I assume you want "one" SQL string to get 3 tables.

Where you get from table 1 least say one datarow in a table.
In table 2 the rows from the related key in table 1
in table 3 the rows from the related keys in table 2

Because I don't like (hate) SQL, I think it is better that somebody else
give you this answer.

Or you should like to do it with 3 seperated SQL strings where you can
than create in a for loop your own sql string with a where or clause for
the third table from the second

http://msdn.microsoft.com/library/de...ca-co_2y2h.asp

Just an idea, not great

Cor

"jaYPee" <hi******@yahoo.com>
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.


Nov 21 '05 #4
If you are having performance problems first thing to check is if you have
indexes on your tables. Also, is your query slow only in VB.Net or is it
also slow when you run it in TSQL ?

How many records are you feasibly planning on showing in the front end screen?
Are you planning on retrieving all 90,000 from this 3rd table ?

I tend to use the Reader when dealing with large data queries into VB.Net.

"jaYPee" wrote:
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.

Nov 21 '05 #5
A 3 table join is easy...

Using the SQL Server Northwind database, this query selects the category
name for all products with a quantity greater than 3 in order details (just
a random query)

Select Distinct C.CategoryName
FROM [Order Details] OD
INNER JOIN Products P on P.ProductID = OD.ProductID
INNER JOIN Categories C on C.CategoryID = P.CategoryID
WHERE OD.Quantity > 3
"jaYPee" <hi******@yahoo.com> wrote in message
news:7j********************************@4ax.com...
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.

Nov 21 '05 #6
If it's not important that you have absolutely correct data,
try using the WITH(NOLOCK) hint in your SQL.

Also, as someone else mentioned, use profiler to record some activity ansd then feed the
profile data into the query analyzer index tuning wizard. These two steps should help out
to some extent. Of course, reducing the number of rows you are working with through where
clauses is a great way to speed things up. A general rule of thumb is that if your query
takes more than a second, figure out a better way to run it.

GL
"jaYPee" <hi******@yahoo.com> wrote in message
news:7j********************************@4ax.com...
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.

Nov 21 '05 #7
I want to second Frans Bouma's reply - don't retreive that many records in
one go. I understand you should have a chunky not chatty interface, and
retreive as much as you can - but that doesn't mean retreive the lion, the
mouse and their children and their grandmothers with your data. There is
again no hard and fast rule about "how much is how much" - but 90,000 rows
is too much beyond doubt. A 1000 is hitting the limits of too much IMHO -
but anyway.

Have you considered what will it take to DataBind 90,000 rows to the UI?
I just answered another question on this newsgroup recently on which a nice
dude had 100,000 rows in a datatable and to remove half of them it took him
30+ SECONDS (yes not milliseconds).

Also imagine the kind of memory you are using up. (LOTS).

The beauty of ADO.NET is that you can call SqlDataAdapter.Fill multiple
times on the same dataset - why don't you fill the third table on demand -
and fill it with fewer rows? .. i.e code up another stored proc that accepts
an ID from Table2 as a parameter, and returns you rows matching *only* that
id.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


"jaYPee" <hi******@yahoo.com> wrote in message
news:7j********************************@4ax.com...
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.

I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000 records as of now.

I tried to limit the number of records to return by a select command
using the criteria but my problem is I dont know how to limit the
number of records return by a 3rd table (grandchild).

I'm using textboxes in parent table and datagrid in 2nd and 3rd table.
There is no problem querying the 1st and 2nd table but I don't know
how to query the 3rd table. 3rd table must know first the primary key
value of the 2nd table that is stored in a datagrid. but don't know
how to do this.

Anyone know what is the better way to access this data?

I would love to read some article about techniques on accessing table
that has a relationship up to 3rd table (grandchild).

thanks in advance.

Nov 21 '05 #8
Sahil,

That is often said too jaYPee in the language.vb newsgroup, I assume that is
the reason he is optimizing now his datasets.

However he is now telling in my opinion that he has 90.000 rows in his
database, any clue to optimize that, because that can be really interesting
when you are able to give that when you do not know what kind of database
table that is and not know if it is already completly optimized.

:-)

Cor
Nov 21 '05 #9
Cor Ligthert wrote:
Sahil,

That is often said too jaYPee in the language.vb newsgroup, I assume that is
the reason he is optimizing now his datasets.

However he is now telling in my opinion that he has 90.000 rows in his
database, any clue to optimize that, because that can be really interesting
when you are able to give that when you do not know what kind of database
table that is and not know if it is already completly optimized.


As he uses a master - detail - superdetail setup, it depends on which
grid will be the main source of information to the user. I.e.: will he
browser hte detail a lot (and thus changing the superdetail grid a lot)
or not. These setups are typically well served with a load-on-demand
scenario. This means that when the user changes for example the selected
index in the detail grid, the logic tries to determine if there are rows
loaded for the superdetail grid for that particular detail row. If not,
fetch them from the db. (so initially start with an empty superdetail
table).

This also avoids having tens of thousands of rows in a datatable which
can't deal very well with more than 57000 rows. It also avoids having to
bind thousands of rows to a grid, as the maser -> detail grid can be
solved with the same trick.

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog : http://weblogs.asp.net/FBouma
Microsoft MVP (C#)
Nov 21 '05 #10
Cor,

I agree that the queries have to be optimized, but even if we assume the
best possible case, lets say the dataset actually lives prepared in a memory
mapped file, that you just have to do a load on - there still are the issues
of binding it and browsing it and the memory it consumes. It is going to
instantiate 103,000 datarows, and setup appropriate relations. And I don't
even want to think of what it takes to bind/browse 103,000 rows
appropriately.

No matter how fast the queries run, in my opinion the best solution would be
to reduce the dataset size by changing the UI a little bit. Once you have
that squared away, along with good Sql Queries you'd have a good practicable
solution.

And if he is asking us to optimize a datapull from 90,000 rows - then we
need to see the table structures and sql statements to comment accurately.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Sahil,

That is often said too jaYPee in the language.vb newsgroup, I assume that
is the reason he is optimizing now his datasets.

However he is now telling in my opinion that he has 90.000 rows in his
database, any clue to optimize that, because that can be really
interesting when you are able to give that when you do not know what kind
of database table that is and not know if it is already completly
optimized.

:-)

Cor

Nov 21 '05 #11
Sahil,

jaYpee is in my opinion not talking about a dataset.

He is in my opinion talking about a database, from which he wants a limited
dataset which is as small as possible.

Where do you guys read a dataset of 90.000 datarows?

Cor
Nov 21 '05 #12
On Thu, 2 Dec 2004 15:48:49 +0100, "Cor Ligthert"
<no************@planet.nl> wrote:
Sahil,

jaYpee is in my opinion not talking about a dataset.

He is in my opinion talking about a database, from which he wants a limited
dataset which is as small as possible.

Where do you guys read a dataset of 90.000 datarows?

Cor


Sorry for the delayed response 'cause i have attended a seminar last
week.

Thanks for the reply. You are exactly right with your opinion. I just
want to optimize my code to make it faster. My scenario is the same
with the sample from microsoft called " VB.NET - Data Access - Build a
Master-Detail Windows Form". I have build the same concept w/ this
sample. The problem here is when there are so many parent records in
the database and many many more records in the child form (1st and 2nd
datagrid). So when the form loads say for example based on the sample
from microsoft if it has 3,000 parent records and 10,000 child records
and 90,000 grand child records the loading of form is so very slow
using the dataadapter.fill method. In order to solve this problem I
have to pull out only the data based on the criteria that the user
needs. But my problem now is on how can I filter the to child table.

thanks again...
Nov 21 '05 #13

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

Similar topics

10
by: Bob Bedford | last post by:
Sorry if I post here, but I don't have access to any valuable mysql ng for this question, ans since 99% or php programmers deal with mysql, I'm sure I'll get an answer here. Look at the...
5
by: yvan | last post by:
Approximately once a month, a client of ours sends us a bunch of comma-delimited text files which I have to clean up and then import into their MS SQL database. All last week, I was using a Cold...
10
by: DaveDiego | last post by:
I've had a user delete one of the client records, I do have a version of the DB with all records intact before the deletion occured. Whats the best approach to getting all the related records in...
2
by: Steve | last post by:
I am developing an asp.net 2.0 application and have come across the dilemma of how to store constant values, which change infrequently. The website will have tens of thousands of visitors every...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
2
by: Bob | last post by:
I got three related datagrid views one parent and two children of the same. The two child tables contain many thousands of records and some of the contents are bitmap files in a sql server...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
4
by: LetMeDoIt | last post by:
Greetings, I'm using ASP to retrieve from MSSQL and I then populate a table. After several months of successfull retrieves, this same code now bombs out. It turns out that if I clear out from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.