473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flexible back-end data handling in .net + sql project

Hi guys,

Got a problem now :( please help...

now we got a project handling records saved in a table in a sql
2000(will upgraded to 2005 soon) server. every month around a million
records will be inserted.

now user raised a request, that is, once criterios are matched, the
project should do some backend handle, for example, if

SELECT colID, fieldC, fieldD FROM dataTable WHERE fieldA =
'fieldA_valueB'

returns some recordset, for each @fieldC, @fieldD we shall do some
back-end trick, maybe

UPDATE dataTable SET fieldE = 'fieldE_valueF' WHERE fieldC = @fieldC
AND fieldD = @fieldD

let's say such a rule is named as rule01. Hope I'm expressing the
problem clearly?

my questoin is, shall we do this in Database side, using triggers, or
by informing our .net project to do it?

1. since the records are coming around 1 millison per month, how can we
handling the performance issue?

2. now the rules are still somewhat simple, seems at least we could do
it by EXEC or SP_EXECUTESQL. but rules may turn quite complex, for
example, audit log, or more complex issues, shall we do it in .net
program? but how can a trigger in SQL database informing a .net
program, or webservice, or windows service? by executeing an executable
console program?

3. user may raise more and more rules, how could we provied a flexible
solution? i mean we're trying to build it less hard-coded. seems in sql
database EXEC or SP_EXECUTESQL are still somewhat flexible, while in
..net to do something like eval() in javascript or EXEC in sql server is
a little bit troublesome. but, put all these bussiness logic in stored
procedure sounds a little bit weired.

guys, hope i have made myself clear. any suggestion? Thanks very mcuh

yours,
athos.

Nov 23 '05 #1
7 1508
1. You certainly ought to do this set-based rather than row by row as
your code fragment implied. What you can also do is batch the UPDATEs
into X rows at a time. For example:

SET ROWCOUNT 50000

WHILE 1=1

BEGIN

UPDATE dataTable
SET fieldE = 'fieldE_valueF'
WHERE EXISTS
(SELECT *
FROM dataTable AS T
WHERE fieldA = 'fieldA_valueB'
AND T.fieldC = dataTable.field C
AND T.fieldD = dataTable.field D);

IF @@ROWCOUNT = 0 BREAK

END

SET ROWCOUNT 0

2. Why would you want to do audit logging in the front end? I don't
understand the question.

3. What is your reason for wanting dynamic code rather than static?
This just comes down to change management controls. Dynamically
altering fundamental chunks of business logic without a release and
test cycle is a great recipe for really screwing things up. Would you
consider doing the same thing for C# code? I don't think so.

--
David Portas
SQL Server MVP
--

Nov 23 '05 #2
Dear David,

thanks for your time.

1. for performance, i mean, as the records are coming at around 1
million per month, when this project comes to production we'll have
around 100 months' records loaded, while, for each month, less than
1000 triggers will happen, so every month we are going to look for 10^3
records in 10^8 records, just like to find a small fish in a big pond.
as our developing is going somewhat well, user said they may want a
daily update, which means searching for 50 records in around 10^8
records, and update, i'm worried about the performance.

2. this is a finance project so every change will be recorded for
audit. well, the point is, the back-end trick may be quite complex,
while i feel it's better to do complex calculation and handling in
..net, there are more tools, for example, RegExp. To be frank, this is
an in-house developed project while our users are too strong for not
even me, but my HOD to argue. Maybe sql 2005 will be just powerful
enough, but I really don't know how complex the request will be, or how
far will our dear users go. that's why I'm wondering whehter shall do
the bussiness logic in .net, in this case we need to invoke the .net
from sql database side, which way will be the best way to do so?

3. good point, i'm convinced. i'll report to users. u know, my users
are quite ad hoc in techniques, using ipod, wanting everything dynamic,
while never worries about coders' headache. thanks.

thanks David, please consider issue 1 and 2. really apperciate your
help.

yours,
athos.

Nov 23 '05 #3
1. 50 rows out of millions isn't a problem in principle. Having the
right indexes in place will very important but there's no reason to
assume that performance will be poor just because you have millions of
rows.

2. The database is surely the best place for your audit trail because
there are obvious advantages (performance / storage / bandwidth) to
keeping the audit and data in the same location. Triggers and audit
table(s) are pretty much the standard solution for this. In SQL Server
2005 you can put .NET code in the database too so there shouldn't be
any technical obstacles to implementing what's required server-side.

--
David Portas
SQL Server MVP
--

Nov 23 '05 #4
1. man, i'm not talking about 50 in a million, but 50 in 10^8, which is
100 million .. will this be OK?

2. good news to hear, seems my booking the .net rock at Nov.29 is a
smart decision :)

thanks David.

Nov 23 '05 #5
"athos" <at*******@gmai l.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
1. man, i'm not talking about 50 in a million, but 50 in 10^8, which is
100 million .. will this be OK?


Why shouldn't it be OK? Take a look at wintercorp.com who recently listed a
SQL Server database with 67 billion rows.

With the right hardware and implementation such things are perfectly
possible. However, design and implementation of an efficient scalable
database requires skill and experience. I'd say that you should be asking
these questions of the people who will design and build your database. If
you don't already have that expertise available to you then start hiring.

Hope this helps.

--
David Portas
SQL Server MVP
--
Nov 23 '05 #6
thanks David, i don't have such an expertise and it's not me to hire,
but your wintercorp sample give me quite some encouragement. thanks!

Nov 23 '05 #7
David Portas (RE************ *************** *@acm.org) writes:
1. You certainly ought to do this set-based rather than row by row as
your code fragment implied. What you can also do is batch the UPDATEs
into X rows at a time. For example:

SET ROWCOUNT 50000

WHILE 1=1

BEGIN

UPDATE dataTable
SET fieldE = 'fieldE_valueF'
WHERE EXISTS
(SELECT *
FROM dataTable AS T
WHERE fieldA = 'fieldA_valueB'
AND T.fieldC = dataTable.field C
AND T.fieldD = dataTable.field D);

IF @@ROWCOUNT = 0 BREAK

END

SET ROWCOUNT 0


Note that in SQL 2005, this is better written as:

WHILE 1=1
BEGIN
UPDATE TOP 50000 dataTable
SET fieldE = 'fieldE_valueF'
WHERE EXISTS
(SELECT *
FROM dataTable AS T
WHERE fieldA = 'fieldA_valueB'
AND T.fieldC = dataTable.field C
AND T.fieldD = dataTable.field D);
IF @@ROWCOUNT < 50000 BREAK
END

The TOP is new syntax, which Microsofts recommend over SET ROWCOUNT,
as it is more optimizer-friende. The change for the check on @@rowcount
is just a small optimisation.

I also like to add that in my experience is that for these batching-
operations to be meaningful, you should base the batch on the clusrered
index of the table. Else the time it takes for SQL Server to locate the
rows in the batch can be expensive.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 23 '05 #8

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

Similar topics

0
4568
by: Punky | last post by:
Hi all, I've gotten a long way with my application, but now it's generating an error to which I know no response. I hope any of you can (and will) help me. Below is the code. It's a simple piece of code which should select a flexible range (one column wide) on one worksheet and copy it to another. Where things go wrong is in the last part of the code, for some reason the range is not selected properly. I've tried adding quotation marks...
1
1590
by: Boštjan Jerko | last post by:
Is there a way to pass list with flexible length to C extension? I want to pass flexible length list of floats to method and just can't get info if it is possible and how to do it. Thanks, B.
58
4700
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split (PHONE_LIST, "_+")) { Console.WriteLine (phoneNumber); } } Output: 495.1000
3
1498
by: Matt Silberstein | last post by:
I have a page that is going to have a number of times, call them A1, A2, A3, etc., B1, B2, B3, ..., and C1, C2, C3. I am not sure about the layout now, and may want to play with it. Most likely I will either want one of these three layouts: A1, B1, C1, A2, B2, C2, ... or All of the Cs on the right side and then either A1, B1, A2, B2, ... or B1, A1, B2, A2, ... Can I figure that I can do this entirely with styles or am I going to have...
10
6697
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
2
10326
by: Christopher Benson-Manica | last post by:
Is the following program conforming under C99? #include <stdio.h> typedef struct foo { int bar; int baz; } foo; foo foos={
2
2998
by: DevarajA | last post by:
Can someone help me understand what flexible array members exactly are, how they behave and how could them be implemented by a i386? Also I didn't understand the two exceptions that the standards talks about (when talking about ignoring the flexible array member). Please help me. -- Devaraja (Xdevaraja87^gmail^c0mX) Linux Registerd User #338167 http://counter.li.org
8
2474
by: ulyses | last post by:
I'm trying to put pointer to flexible array of structures in other structure. I want to have pointer to array of pixels in screen structure. Here is mine code, but I think it isn't quite all right: struct pixel { int x; int y; int color; };
20
1819
by: mechanicfem | last post by:
I thought (as they're in c99) that flexible arrays were there for a number of reasons - but I also thought they'd be great for stepping into structures (say) that were aligned in memory after (say) a header struct, e.g.: struct element { int a; int b; };
3
3892
by: Hallvard B Furuseth | last post by:
to find the required alignment of a struct, I've used #include <stddef.h> struct Align_helper { char dummy; struct S align; }; enum { S_alignment = offsetof(struct Align_helper, align) };
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.