all groups > sql server programming > january 2005 >
You're in the

sql server programming

group:

A lot of lockings and connections to SQL Server. Is it normal or bad?


Re: A lot of lockings and connections to SQL Server. Is it normal or bad? Louis Davidson
1/3/2005 9:44:30 AM
sql server programming:
This is the open question of all times. Without looking at the code, the
best that can be said is that you might be fine, or you might have written a
terrible app (something we all have done at one time or another :) Lots of
locks are fine, as long as you don't have lots of users contending for those
locks. You say you have 8 users, is that all you are planning for? If
everyone is happy, it might be fine.

Bottom line is that you need to get some literature and read up on design,
internals, optimization, etc before you can decide if your application is
well written, and experience is a must. Without being able to magically
aquire this (and it takes a while and sadly we learn from failure!) I would
suggest that you take this statement:

[quoted text, click to view]

Define what max means and test for it. If it works fine under max
conditions, then your application is fine.

--
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP

Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)

[quoted text, click to view]

A lot of lockings and connections to SQL Server. Is it normal or bad? Willianto
1/3/2005 9:32:43 PM
Hi all,

First of all:
*** HAPPY NEW YEAR TO YOU ALL!!! :) ***

then, here it goes; I've downloaded SQL Spy 6.0 from Hybridx (got it
from http://files.webattack.com/localdl834/sql_spy_setup.zip). It's a
freeware tools to monitor SQL Server activity. I use this tool to watch
how my apps (created with Microsoft Visual FoxPro 8.0 SP1, connect with
SQL Server thru ODBC) interact with SQL Server. I found out that on some
parts of my apps (where there are lots
of traverse and calculation), the number of locks on the SQL Server
could go up to 700 and the external connection could go up to 15 or 20.
And I tested that on my box (that means; I run my apps on the server and
no workstation connect to the server).

Whilst the apps so far running fine, it's never been really tested to
the max. The traffic are quite low and the concurrent user has never
exceed eight users. Yet, looking at the numbers, I'm afraid that there
something that I don't do effectively.
My Questions:
1. Is the number normal?
2. Anybody here can give me advices on C/S programming, I mean just a
quick thumb rules what should and what, like should I make a connection,
get the data, and disconnect immediately. Or should I share all SPT in
one connection?, or any other rule what should and shouldn't?

Thanks in advance

Willianto

Re: A lot of lockings and connections to SQL Server. Is it normal or bad? Willianto
1/5/2005 10:04:22 AM
Hi Louis:

Thanks for your reply.
[quoted text, click to view]
Lots of .. [skipped]
Looks like my case is the second one :(
As I stated in my post, the application runs fine, but it runs with a
very minimum load. That's because the company using my apps is a
machinery trading company. The activity is very low. To give you a clue
how 'low' is that; they only have to create less than 10 invoices a day.
Actually, that's the best numbers they got for years (that means less
than ten sales a day - but, hey, the profit of selling one machine could
cover three months expenditure!). Anyway, what I did is I backup the
database, call up some of my fellow, line up eight computers, and
massively attack the system with all the apps feature (purchasing,
receive goods, stock preview, stock opname, delivery order, customer
order, etc...). After an hour we manage to hang the server which by
then, got about 350,000 locking and 80,000 external connections :(

So, using SQL Server as a backend is not _that_ easy... Oh well, at
least I know for sure that the problem won't appear in my client for a
near future.

Regards,
Willianto

[quoted text, click to view]

Re: A lot of lockings and connections to SQL Server. Is it normal or bad? Louis Davidson
1/5/2005 12:21:27 PM
Yeah, I think the telltale sign here is the 80,000 connections. You are
probably not closing a connection in your application somewhere. This can
actually be dangerous if you are using any transactions in your code (not
using transactions is dangerous for other reasons, like data integrity!)

[quoted text, click to view]

It isn't that bad though. Just like any code you have to be careful to
clean up after yourself when you connect to and use a resource. Either way,
understanding the need for improvement is step number one, and if the
application is meeting all of your current needs without much troublem,
sounds like you have time to isolate the issues.

--
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP

Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)

[quoted text, click to view]

Re: A lot of lockings and connections to SQL Server. Is it normal or bad? Willianto
1/6/2005 9:09:48 AM
Hi Louis:

Thanks for your time. I've manage to put a quick-and-dirty code to close
all connections used by the form on its Destroy event (occur when the
form object is about to be destroy - a credit goes to VFP community in
microsoft.public.fox.programmer.exchange). It's less than 10 lines of
code, but it sure clean up the mess.

Thanks again!

Regards,
Willianto

[quoted text, click to view]

Re: A lot of lockings and connections to SQL Server. Is it normal or bad? Louis Davidson
1/6/2005 11:34:59 AM
Good deal. It sounded like it was probably something that a small change to
fix a really large problem.

--
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP

Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)

[quoted text, click to view]
AddThis Social Bookmark Button