Showing posts with label sounds. Show all posts
Showing posts with label sounds. Show all posts

Friday, March 30, 2012

long transaction

Hi,

I am still not very proficient in SQLServer. So apology if the
question sounds basic.

We have a script to clean old unwanted data. It basically deletes
all rows which are more than 2 weeks old. It deletes data from
33 tables and the number of rows in each table runs into few millions.
What I see in the script (not written by me :-) ) is that all data is
deleted within a single BEGIN TRANSACTION and COMMIT TRANSACTION. As
I have background in informix, such an action in Informix may result
in "LONG TRANSACTION PROBLEM". Does SQLServer have a similar concept.

Also won't it have performance problem if all rows are marked locked
till they are committed.

TIA."rkusenet" <rkusenet@.sympatico.ca> wrote in message
news:bq071h$1tbn6v$1@.ID-75254.news.uni-berlin.de...
> Hi,
> I am still not very proficient in SQLServer. So apology if the
> question sounds basic.
> We have a script to clean old unwanted data. It basically deletes
> all rows which are more than 2 weeks old. It deletes data from
> 33 tables and the number of rows in each table runs into few millions.
> What I see in the script (not written by me :-) ) is that all data is
> deleted within a single BEGIN TRANSACTION and COMMIT TRANSACTION. As
> I have background in informix, such an action in Informix may result
> in "LONG TRANSACTION PROBLEM". Does SQLServer have a similar concept.

I'm not sure what the "LONG TRANSACTION PROBLEM" in Informix is, but yes,
you basically don't want transactions to run for long periods of time.

As you point out, this can cause blocking on reads depending on your
isolation level. In addition, it can make recovery that much harder.

Assume your transaction takes 20 minutes to run (that's a really long time
admittedly) and your server gets rebooted 19 minutes into it. You're
looking at probably at least 19 minutes of rollback time when you reboot.
During this time the database will be completely inaccessible.

You have a couple of options that depend on your environment.

One is to simply break this up into multiple transactions. Of course then
it depends on what happens if one fails. Does this matter to other
transactions? Are their any dependencies?

It may also be possible to copy the needed data into a temp table, truncate
the original table and move data back.

But regardless, I would try to redesign this.

> Also won't it have performance problem if all rows are marked locked
> till they are committed.
> TIA.|||"rkusenet" <rkusenet@.sympatico.ca> wrote in message news:<bq071h$1tbn6v$1@.ID-75254.news.uni-berlin.de>...
> Hi,
> I am still not very proficient in SQLServer. So apology if the
> question sounds basic.
> We have a script to clean old unwanted data. It basically deletes
> all rows which are more than 2 weeks old. It deletes data from
> 33 tables and the number of rows in each table runs into few millions.
> What I see in the script (not written by me :-) ) is that all data is
> deleted within a single BEGIN TRANSACTION and COMMIT TRANSACTION. As
> I have background in informix, such an action in Informix may result
> in "LONG TRANSACTION PROBLEM". Does SQLServer have a similar concept.
> Also won't it have performance problem if all rows are marked locked
> till they are committed.
> TIA.

If the data is unwanted, it seems unusual to delete it like that,
unless there really is a genuine requirement to do it inside a single
transaction. A large transaction like that can easily cause
performance and locking problems.

Assuming there isn't a real need to use a single transaction, then you
could do batch deletes instead, perhaps as an overnight maintenance
job to prevent users seeing unexpected results if they run queries
during the deletion.

Simon|||"Simon Hayes" <sql@.hayes.ch> wrote
> If the data is unwanted, it seems unusual to delete it like that,
> unless there really is a genuine requirement to do it inside a single
> transaction.

I don't see any such requirement. It can always continue next time if
the delete fails for some reason.

> A large transaction like that can easily cause
> performance and locking problems.

That's what I thought.

> Assuming there isn't a real need to use a single transaction, then you
> could do batch deletes instead, perhaps as an overnight maintenance
> job to prevent users seeing unexpected results if they run queries
> during the deletion.

I plan to remove BEGIN and COMMIT. This way each delete will be atomic
by itself.

thanks.

Monday, February 20, 2012

Login Page Using SQL DB

I apologize because this question is probably so amazingly simple it sounds retarded, but I am a 100% newbie to ASP.NET --

I am using WebMatrix to create an ASP.NET login page (coding in VB), and I have a SQL server with a table in it called "LoginInfo". That table has three fields, "PrimaryKey", "UserID" and "PIN".

Basically, the goal is that the user goes to the page and enters their UserID and PIN into two different boxes and then pushes a button and it logs them into the page. My problem is, I have the UserID/PIN text boxes, I have the button, I have the SQLDataConnection (I just dragged the table from the Database onto the page and it made it for me), but I don't know what to do at all now.

How do I have the UserID text box check against the UserID's pulled from the table in the SQL server, and how do I have the PIN numbers check against the PIN numbers pulled from the SQL table, and then if they match up let the user into the site?

I'm sorry if this is a lengthy question to answer or if it is so simple its irritating, as I said I am a complete newbie.Have you gone through theASP.NET Web Matrix Project Guided Tour? There is a section called "Build an End-to-End Application" which containsCreate Login page that should help you.

Terri|||Thanks a TON tmorton, you're the best. This is a great resource I hadn't known about. I just read the entire thing for the login page and it's excellent. I will be reading many of the other tutorials also.

Thanks a million!|||There are lots of other resources for ASP.NET Web Matrix, and here are 2 more free ones that should not be missed:

Inside ASP.NET Web Matrix, which is a .PDF file containing a free online book by Alex Homer and Dave Sussman.

The .NET Show: ASP.NET Web Matrix with Microsoft's Scott Guthrie and Nikhil Kothari.

And also, there is a forum here specifically for ASP.NET Web Matrix:view forum 30

Glad to help!

Terri