I have heard that the most time consuming task into a DB is the when we use
the Insert Statatement,
Is that true?
Ok I have an application that sends from 10 to 500 rows to the DB, those
rows are compared again a fixed value and then they are inserted to the DB i
f
the comparison is ok.
I would like to do all that inside the DB (a SP) but I don’t know how, so
I
created a WebService to do that, my point is that I’m not inserting row by
row instead I hold the rows in a Dataset (memory) and later I make one big
insert to the DB.
My question is should I leave that code like this or should go to the DB in
order to insert row by row to gain some performance?
Can you think a better way to do that, because that is the heart of my app
and I want to minimize the time it takes.
Thnks.
Kenny M.Hi Kenny
Please let me know what kind of comparision is that u are doing before
inserting rows into your database.
Just try avoiding bringing data to the front-end if its only a validation
part.
You can write a query as:
INSERT INTO <TABLE>
SELECT <Columns>
FROM <another table>
<WHERE Condition>
alternatively you can also write INSTEAD OF Triggers, if you want to check
the records before they are inserted
hope this will solve the problem
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Kenny M." wrote:
> I have heard that the most time consuming task into a DB is the when we us
e
> the Insert Statatement,
> Is that true?
> Ok I have an application that sends from 10 to 500 rows to the DB, those
> rows are compared again a fixed value and then they are inserted to the DB
if
> the comparison is ok.
> I would like to do all that inside the DB (a SP) but I don’t know how, s
o I
> created a WebService to do that, my point is that I’m not inserting row
by
> row instead I hold the rows in a Dataset (memory) and later I make one big
> insert to the DB.
> My question is should I leave that code like this or should go to the DB i
n
> order to insert row by row to gain some performance?
> Can you think a better way to do that, because that is the heart of my app
> and I want to minimize the time it takes.
> Thnks.
> --
> Kenny M.|||Hi, Well
In order to understand it better, the table Category is like this
CategoryID Number SetAmount
1 0 1000
1 ... ...
1 999 2000 For each Category there
are 1000 numbers
2 0 200
2 ... ...
2 999 3000
.. ... ...
n 0 - 999 ...
e.g
I send 100 rows to the method . The rows are like this
ID,DATETIME, NUMBER,AMOUNT,CATEGORYID
For each row I have to go to the categorytable look for the CATEGORYID then
look for the NUMBER and ask if the AMOUNT is > SetAmount. If so I have to
Insert the Whole Record into another table.
At this time I'm doing that process inside a WService.
I'm not inserting row by row, instead I'm saving the valid row in a DataSet
to later Insert them to a Table.(Using Fill method)
Any sug.
thks.
Kenny M.
"Chandra" wrote:
> Hi Kenny
> Please let me know what kind of comparision is that u are doing before
> inserting rows into your database.
> Just try avoiding bringing data to the front-end if its only a validation
> part.
>
> You can write a query as:
> INSERT INTO <TABLE>
> SELECT <Columns>
> FROM <another table>
> <WHERE Condition>
> alternatively you can also write INSTEAD OF Triggers, if you want to check
> the records before they are inserted
> hope this will solve the problem
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
> ---
>
> "Kenny M." wrote:
>
No comments:
Post a Comment