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

Design Issue

Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose

Nov 27 '06 #1
10 1413
Hi Jose,

What do you mean by "complex calculations"?

If you're using Sql Server 2000 there are some mathematical and statistical
aggregate functions that you might be able to use. Control-of-flow language
elements are available as well, such as IF and WHILE.

Sql Server 2005 hosts the CLR so you can define stored procedures in C# if
you want.

"Using CLR Integration in Sql Server 2005"
http://msdn2.microsoft.com/en-us/library/ms345136.aspx

"CLR Stored Procedures"
http://msdn2.microsoft.com/en-us/library/ms131094.aspx

If you're not using Sql Server 2005 then you can try to limit the number of
records returned based on filter criteria extracted from the full algorithm,
if possible, and then run the full algorithm on the client. If you can't
find any simple filter criteria to use then I don't think you have any
choice but to pull all of the records for processing on the client.

--
Dave Sexton

"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose

Nov 27 '06 #2
Hello jose,

jI have a table of data that could run to about 50,000 rows. A user
jwill enter a some data in a web form and I need to return a paged set
jof results depending on the value of the data.

Have u studied the features of your DB to perform this? For example MSSQL2005
has support of paging.

jHowever I cannot
jprocess this value in SQL I need to perform some complex calculations
jthat can only be done in code.

Are they really so specific? Which DB do u use that you can't move it to db?

jMy question is this, is there a better
jway than returning all the rows (just the values I need not the
jentire row) run the processing query and then display 10 records? It
jjust seems a bad way to get 10 records!!!

So, if you need to calculate smth where all rows involved there is no other
way.
Can u describe what are u trying to do?

You can tune a process of data consuming using DataReader instead of DataSet

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 27 '06 #3
On 27 Nov 2006 12:32:33 -0800, Jose wrote:
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose
Look at the ROW_NUMBER() function on SQL Server:
http://davidhayden.com/blog/dave/arc...2/30/2652.aspx

Cheers,
Gadget
Nov 27 '06 #4
Hello Jose,

If you share some of the details of your "complex calculation," I think you
will discover that some of the folks on this helpful board are able to show
you how to precalculate many of the values that you then need to use in your
search criteria.

For example, say you want to find all invoices where the average value per
line exceeds $100. Let's say you have 50,000 invoice headers and >200K
invoice rows. It would be prohibitively expensive to run this query without
precalculation.

On the other hand, if you simply added a column to the invoice header table
that stores the average value per invoice line for the entire invoice, then
the query is not only fast, but completely trivial. You simply have to
perform the calculation in advance, whenever the invoice itself is written.

Clearly, this is an overly simplistic example, and it may not be anything
like the problem you are facing. On the other hand, without further
information, you leave folks like us to guess, and we cannot be completely
helpful.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose

Nov 28 '06 #5
You can write complex calculations in a Stored Procedure.

--
HTH,

Kevin Spencer
Microsoft MVP
Virtual Carpenter
http://unclechutney.blogspot.com

Paranoia is a state of mind.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose

Nov 28 '06 #6
Thanks for all your emails.

In retrospect it was quite cryptic to say "complex calculations"!!
Basically I am storing longitude and latitude data for various
geographical sites. This may imply that there may not be many rows in
the db but each site can have a number of items. A user can enter
his/her address and say "show me all the sites within 200 metres of my
location". I am using a 3rd party component to calculate the distances
between the user's location and that of the site - that is why I cannot
move it to the DB (or so I am assuming).

I am using ASP.net 2.0 and SQL 2K.

Thanks again,

Jose

Kevin Spencer wrote:
You can write complex calculations in a Stored Procedure.

--
HTH,

Kevin Spencer
Microsoft MVP
Virtual Carpenter
http://unclechutney.blogspot.com

Paranoia is a state of mind.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose
Nov 28 '06 #7
It's worth telling people which version of SQL server you're using when you
ask a question so they don't waste time helping you with an inapplicable
solution.

If your coordinates are stored in a numeric format then you don't need an
external function as it's simple trigonometry, and you can narrow your
comparison down to a 70% match probability before doing any trig math by
looking at the square around your required location. This would use any
index on your X and Y coordinates, making it very fast.

If you're not storing your coordinates as numeric values then you should
be, and you could do this via computed columns, or by setting them when
loading data externally.

What Datum are you using for your coordinate data?

Cheers,
Gadget

On 28 Nov 2006 10:51:25 -0800, Jose wrote:
Thanks for all your emails.

In retrospect it was quite cryptic to say "complex calculations"!!
Basically I am storing longitude and latitude data for various
geographical sites. This may imply that there may not be many rows in
the db but each site can have a number of items. A user can enter
his/her address and say "show me all the sites within 200 metres of my
location". I am using a 3rd party component to calculate the distances
between the user's location and that of the site - that is why I cannot
move it to the DB (or so I am assuming).

I am using ASP.net 2.0 and SQL 2K.

Thanks again,

Jose

Kevin Spencer wrote:
>You can write complex calculations in a Stored Procedure.

--
HTH,

Kevin Spencer
Microsoft MVP
Virtual Carpenter
http://unclechutney.blogspot.com

Paranoia is a state of mind.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegr oups.com...
>>Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose
Nov 28 '06 #8
It is certainly possible to do distance calculation from lat/long data in a
Stored Procedure. There are a variety of techniques for doing this, some of
them relatively simple and less accurate, and some of them relatively
complex and more accurate. However, you would not be able to use your
3rd-party component to do this. You would have to either find or write the
algorithms for yourself. If you want to do this, I can make some
suggestions.

--
HTH,

Kevin Spencer
Microsoft MVP
Logostician
http://unclechutney.blogspot.com

Parabola is a mate of plane.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Thanks for all your emails.

In retrospect it was quite cryptic to say "complex calculations"!!
Basically I am storing longitude and latitude data for various
geographical sites. This may imply that there may not be many rows in
the db but each site can have a number of items. A user can enter
his/her address and say "show me all the sites within 200 metres of my
location". I am using a 3rd party component to calculate the distances
between the user's location and that of the site - that is why I cannot
move it to the DB (or so I am assuming).

I am using ASP.net 2.0 and SQL 2K.

Thanks again,

Jose

Kevin Spencer wrote:
>You can write complex calculations in a Stored Procedure.

--
HTH,

Kevin Spencer
Microsoft MVP
Virtual Carpenter
http://unclechutney.blogspot.com

Paranoia is a state of mind.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegr oups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose

Nov 29 '06 #9
Again thanks for the replies.
some of them relatively complex and more accurate...I can make some
suggestions.
If you could make some suggestions that would be very useful.

Thanks,

Jose
Kevin Spencer wrote:
It is certainly possible to do distance calculation from lat/long data in a
Stored Procedure. There are a variety of techniques for doing this, some of
them relatively simple and less accurate, and some of them relatively
complex and more accurate. However, you would not be able to use your
3rd-party component to do this. You would have to either find or write the
algorithms for yourself. If you want to do this, I can make some
suggestions.

--
HTH,

Kevin Spencer
Microsoft MVP
Logostician
http://unclechutney.blogspot.com

Parabola is a mate of plane.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Thanks for all your emails.

In retrospect it was quite cryptic to say "complex calculations"!!
Basically I am storing longitude and latitude data for various
geographical sites. This may imply that there may not be many rows in
the db but each site can have a number of items. A user can enter
his/her address and say "show me all the sites within 200 metres of my
location". I am using a 3rd party component to calculate the distances
between the user's location and that of the site - that is why I cannot
move it to the DB (or so I am assuming).

I am using ASP.net 2.0 and SQL 2K.

Thanks again,

Jose

Kevin Spencer wrote:
You can write complex calculations in a Stored Procedure.

--
HTH,

Kevin Spencer
Microsoft MVP
Virtual Carpenter
http://unclechutney.blogspot.com

Paranoia is a state of mind.
"Jose" <di*********@avandis.co.ukwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi All,

(I realise this isn't a specific dotnet question but I'm using dotnet
to implement it.)

I have a table of data that could run to about 50,000 rows. A user will
enter a some data in a web form and I need to return a paged set of
results depending on the value of the data. However I cannot process
this value in SQL I need to perform some complex calculations that can
only be done in code. My question is this, is there a better way than
returning all the rows (just the values I need not the entire row) run
the processing query and then display 10 records? It just seems a bad
way to get 10 records!!!

Thanks in advance for any suggestions.

Jose
Nov 29 '06 #10
On 29 Nov 2006 10:30:23 -0800, Jose wrote:
Again thanks for the replies.
>some of them relatively complex and more accurate...I can make some
suggestions.

If you could make some suggestions that would be very useful.

Thanks,

Jose
Well without some more information you won't get many more suggestions :)

What datum are you using and what is the table structure?
What is the format of data you are using to query the proximity?
Why are you currently using a third party component? i.e. What's special
about it?

Cheers,
Gadget
Nov 29 '06 #11

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

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
2
by: Kymert persson | last post by:
Hi. I was wondering if there are any more C++ books along the lines of "Large scale C++ software design" by Lakos, J. I.e. concerning larger design issues in close relation to C++. I have made a...
10
by: eMKa | last post by:
Hi Code guru's I have created a user control which has access, and thus makes use of a shared singleton class like: Dim MyAppSettings As DLAppSettings = DLAppSettings.GetAppSettings This...
2
by: John Holmes | last post by:
This, I fear, is related to the fact that Visual Studio.NET reformats the HTML when going into design mode and then back out. I have an object tag that is using an object provided by a 3rd party...
1
by: keliie | last post by:
I have a relatively simple (I assume) issue which I am at a complete loss to address. My issues is: I want to populate fields in my tables with summary data from the same table. Let me explain: ...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
0
by: Paul Hadfield | last post by:
I'm looking for thoughts on the "correct" design for this problem (DotNet 2.0 - in winforms, but that's not so important). I've got two combo boxes (combo1 and combo2), both are populating via...
8
by: obrianpatrick | last post by:
Hi, I am relatively new to object oriented programming and design. I am developing an application in VS 2005. I am having the following design problem: I have two interfaces X and Y. Y is...
5
by: pgrazaitis | last post by:
I cant seem to get my head wrapped around this issue, I have myself so twisted now there maybe no issue! Ok so I designed a class X that has a few members, and for arguments sake one of the...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
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
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
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,...
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
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...

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.