Board index » delphi » doing sql always lock tables in server

doing sql always lock tables in server

i have five clients who made a 'select * from mytable', it has 4.000
records.

Each client lock the table in the server, so when the client number six
try to do
the same query, it stops until one of the five clients close his query.

I have installed sql server 6.5 and small business server
I have made the program in delphi 3 client/server
I have tried with odbc and sql links.
I use tcp/ip connection

Please, Help me.
Thanks

 

Re:doing sql always lock tables in server


Diego,

   Sounds like you are using TTables instead of TQuerys.  Switch to using
TQuerys (and TDataBase for a single connection) and only select the data the
user needs (4000 records sounds like a lot  to me).   You can also use the
NOLOCK query optizer hint.

Select *
From YourTable (nolock)
Where YourTable.Field = 'Whatever'

Good luck,
krf

Quote
Diego wrote in message <37DA50B8.AA3F4...@mx2.redestb.es>...
>i have five clients who made a 'select * from mytable', it has 4.000
>records.

>Each client lock the table in the server, so when the client number six
>try to do
>the same query, it stops until one of the five clients close his query.

>I have installed sql server 6.5 and small business server
>I have made the program in delphi 3 client/server
>I have tried with odbc and sql links.
>I use tcp/ip connection

>Please, Help me.
>Thanks

Re:doing sql always lock tables in server


Im using a Tquery
but i have to show in a dbgrid all properties i have in my table because all
people
will move through the tdbgrid and will select the propertie he wants

if the query show more than 160 records then que server lock the table
im using sql server 6.5.
im using : select * from properties (nolock)
but the server still lock my table

Re:doing sql always lock tables in server


Diego,

   Yes, unfortunately the NOLOCK is just a hint.  SQL server can "decide"
not to use it.  The Books Online has a good explanation of Page locks/Table
locks, but that is not going to solve your problem.  I recommend a re-design
of your table structure.  How many fields are in the table?  Are all the
fields necessary? Do you have indexes created for critical fields?

Good luck,
krf

Quote
Diego wrote in message <37DD0589.F4918...@mx2.redestb.es>...
>Im using a Tquery
>but i have to show in a dbgrid all properties i have in my table because
all
>people
>will move through the tdbgrid and will select the propertie he wants

>if the query show more than 160 records then que server lock the table
>im using sql server 6.5.
>im using : select * from properties (nolock)
>but the server still lock my table

Re:doing sql always lock tables in server


Also check for the transaction isolation. Is well khown that repetable read
transactions in MS SQL scales from record lock to table locks.

Re:doing sql always lock tables in server


This is a short coming of 6.5.  7.0 is better, but I would
recommend Interbase or Oracle, because they automatically do
versioning and don't have this problem.

Quote
Diego wrote:

> i have five clients who made a 'select * from mytable', it has 4.000
> records.

> Each client lock the table in the server, so when the client number six
> try to do
> the same query, it stops until one of the five clients close his query.

> I have installed sql server 6.5 and small business server
> I have made the program in delphi 3 client/server
> I have tried with odbc and sql links.
> I use tcp/ip connection

> Please, Help me.
> Thanks

--
Thomas Miller
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork

http://www.bss-software.com

Re:doing sql always lock tables in server


Welcome to the tricky world of client-server programming.

If the table is locked only by reading you should check the transisolation
level and the locks on that table, use the SQL tools for this.

Another detail - the server locks the table only during the time of the
transaction. If you call TQuery.FetchAll after opening the query, the
reading transaction will finish quite quick (4000 records are not too many
in these days) and the lock will be released. Otherwise the reading
transaction on the server is pending, it completes when the user scrolls
down to the end of the table. Of course FetchAll is a bit slow at the
beginning, but after it the server is released to do other jobs.

Good luck.

Vesso

Quote
Diego <g...@mx2.redestb.es> wrote in message

news:37DA50B8.AA3F49E7@mx2.redestb.es...
Quote
> i have five clients who made a 'select * from mytable', it has 4.000
> records.

> Each client lock the table in the server, so when the client number six
> try to do
> the same query, it stops until one of the five clients close his query.

> I have installed sql server 6.5 and small business server
> I have made the program in delphi 3 client/server
> I have tried with odbc and sql links.
> I use tcp/ip connection

> Please, Help me.
> Thanks

Other Threads