1

I have written a datasnap ISAPI application. I am sending file from client to server using stream. Problem is that it's taking around 1 minute just to send a 3 MB zip file.

My code at client looks like this

TBlobField(ClientDataSetTemp.FieldByName('FileData')).LoadFromFile('c:\test.zip');
ClientDataSetTemp.SaveToStream(MemoryStreamFileData);

At client I tried this too

MemoryStreamFileData:= TFileStream.Create('c:\test.zip', fmShareDenyWrite);

And my server code looks like this

TBlobField(qryTemp.FieldByName('FileData')).LoadFromStream(MemoryStreamFileData);

Any idea how can I improve speed. Thank You.

ary
  • 939
  • 2
  • 13
  • 32
  • When you run a profiler, where does it say the time is being spent? – Rob Kennedy Sep 21 '15 at 22:03
  • Thanks Rob for reply. Are you talking about sql profiler?? If yes then that's not the problem. All the time is spent for stream to reach server. Once it reaches server data is processed within second. – ary Sep 22 '15 at 02:20
  • I wasn't talking about an SQL profiler in particular, but the database code is obviously something you'd want to include in your analysis. I was talking about an ordinary code profiler. – Rob Kennedy Sep 22 '15 at 02:37

1 Answers1

0

TBlobField using ActiveX PBlobObject inherited from Windows OLE BLOB.

Almost problems going from there, just check "https://msdn.microsoft.com/en-us/library/windows/desktop/ms711511%28v=vs.85%29.aspx"

Quick fix of problem can be reached using sql saveto file functions.

Exporting Blob from MySQL database to file with only SQL

Community
  • 1
  • 1
  • Thanks Eugene for reply. I don't have direct connection with SQL Server. I am using ISAPI. So I guess I cannot use the SQL way. – ary Sep 22 '15 at 04:51
  • Ary, if you can say what connector (ADO, dbExpress, another) and sql server are you using. I can give more responsible answer to your question. For example - in ZeosDBO Direct drivers have some functionality to use delphi stream instead mssft, ado and dbExpress have some simple hacks. You are not first who have this problem. pss: Hmm 1 more hint.. If you have using DataSource, create another query without DataSource for files because DataSource eating much resources! – Eugene.LatDev Sep 22 '15 at 05:19
  • Eugene, my ISAPI server has ADOConnection . But for a moment lets say I don't even want to save to SQL Server 2008 R2 database. By manual logging I can see that it takes about 1 minute for file stream just to reach server. – ary Sep 22 '15 at 05:28
  • Ok... How you fetch data from SQL? If "SELECT TOP 1000 id,caption,blob,field1 FROM table ORDER BY id ASC" then you downloads whole data thought connection, it's really freezes whole query. There no pointers for blobs, you get all data via connection to memory, then outputs lines. For some data you must create custom query like "SELECT TOP 1 blob FROM table WHERE id = :id" and give data out of main query. See TBlobField source, there no pointers, there whole data, just class created for custom TField reading. Also that single query can be cached in client app. – Eugene.LatDev Sep 22 '15 at 06:38
  • Eugene. Data is not fetched from SQL. It's just file setting on desktop that I am want to send from client to server. – ary Sep 22 '15 at 14:09