I using SDAC(Standard) long time in my projects together with Delphi 2009 but 2 weeks ago Im change Delphi 2009 with XE2(SP3)... Because HDD is die Im install Win 7 ultimate x64 (Before XP SP3 32bit)...
Last year we have problems with sql server because very often we get locked tables. 1 week ago we are find that problem is with SDAC component when we use TOP in SELECT query. Table is locked no mather if we have setup lockmode to lmNone on query, we are override locking issue when we change IsolationLevel on Connection from default ilReadCommitted to ilReadUnCommitted and now table(When we run select query) is not locked anymore but simple query still take more than 10 seconds.
I will try explain how we reproduce this error...
1.)We have table1 which have cca. 65.000.000 records
2.)On button click we run next query:
Code: Select all
try MSQuery1.SQL.Clear; MSQuery1.SQL.Add('SELECT TOP 20 table1.dt, table1.field1 + ' + QuotedStr(' ') + ' + CAST(table1.field2 AS varchar) AS test1, table1.field3 + ' + QuotedStr(' ') + ' + CAST(table1.field4 AS varchar) AS test2, table1.field5, table1.field6 FROM table1'); MSQuery1.SQL.Add('WHERE table1.fieldx=:fieldx'); MSQuery1.SQL.Add('ORDER BY table1.dt DESC'); MSQuery1.ParamByName('fieldx').Value:='1234'; MSQuery1.Open; finally MSQuery1.Close; end;
If for example fieldx='1234' have more than 20 records but not in last 2 years(records are inserted cca. 1-10/s) it still need 20 seconds or more...
if for example fieldx='1234' have more than 20 records but inserted in last few months records are returned fast but still a lot of slower than ADO return it.
Im try use prSQL and prNative and both produce same result.
Problem is not in SQL Server because ADO component return same result in few ms same as SQL Manager(All three are tested on same PC)!!!