1

I've searched SO for help on this and I think I've exhausted all options.

I have a report that generates about 320k rows and the export to Excel is very slow. So slow that, even after the rendering is over (as shown on the ExecutionLog3) the excel file isn't even created.

I have removed the Report Headers, even have the export to different sheets to create a smaller excel file and there are no merged cells. None of the columns have any formatting. The usual culprits for slow export to Excel, right?

Here is the output from ExecutionLog3

TimeStart               TimeEnd                 TimeDataRetrieval_Secs  TimeProcessing_Secs TimeRendering_Secs  TotalTime_Secs  ReportSizeMB    RowCount    Status      Format          Source
2019-06-12 09:20:57.310 2019-06-12 09:32:41.313 0.000000                0.047000            703.907000          703.954000      55.596719       0           rsSuccess   EXCELOPENXML    Session
2019-06-12 09:17:44.433 2019-06-12 09:20:01.220 33.336000               103.222000          0.080000            136.638000      0.502475        323800      rsSuccess   RPL             Live

Here's the output from the AddionalInfo column for the EXCELOPENXML

<AdditionalInfo>
  <ProcessingEngine>2</ProcessingEngine>
  <ScalabilityTime>
    <Pagination>0</Pagination>
    <Rendering>0</Rendering>
    <Processing>0</Processing>
  </ScalabilityTime>
  <EstimatedMemoryUsageKB>
    <Pagination>32831</Pagination>
    <Rendering>356162</Rendering>
    <Processing>55997</Processing>
  </EstimatedMemoryUsageKB>
  <Connections />
</AdditionalInfo>

For comparison, using the "Get Data from SQL Database" feature from within Excel itself and execute the same SP with the same parameters - the whole process takes about 72 seconds to load the data and display in Excel.

Any ideas on how to improve this export?

2
  • Personal I have never found SSRS Excel export very efficient and 320K rows seems more like a data extract than a report; does it have to be SSRS can you not Just put the query direct in excel? If its does have to be SSRS have you tried csv rather than Excel. Jun 12, 2019 at 11:19
  • @SimonRichardson as stated in the question I've tested the query directly in excel and it's mush faster in comparison. I was thinking I've missed a optimisation trick somewhere. thanks anyway
    – Geezer
    Jun 12, 2019 at 14:17

2 Answers 2

0

Import from SQL Server into Excel and do your aggregation, charting, graphing, etc., in Excel. The sample code below will grab data from SQL Server and pull it into Excel.

Sub TestMacro()

' Create a connection object.
Dim cnPubs As ADODB.Connection
Set cnPubs = New ADODB.Connection

' Provide the connection string.
Dim strConn As String

'Use the SQL Server OLE DB Provider.
strConn = "PROVIDER=SQLOLEDB;"

'Connect to the Pubs database on the local server.
strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=NORTHWIND.MDF;"

'Use an integrated login.
strConn = strConn & " INTEGRATED SECURITY=sspi;"

'Now open the connection.
cnPubs.Open strConn

' Create a recordset object.
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset

With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = cnPubs
    ' Extract the required records.
    .Open "SELECT * FROM YourTable"
    ' Copy the records into cell A1 on Sheet1.
    Sheet1.Range("A1").CopyFromRecordset rsPubs

    ' Tidy up
    .Close
End With

cnPubs.Close
Set rsPubs = Nothing
Set cnPubs = Nothing

End Sub
0

I've found this solution very helpful :

https://social.technet.microsoft.com/Forums/ru-RU/124d54f4-583c-4d6d-ac93-4a8e2971b438/export-to-excel-takes-long-time-in-ssrs-2008?forum=sqlreportingservices

here is a general Idea about this solution :

In Reporting Services, when exporting a report, the report is passed as an interim format to a specific renderer. For excel which was processed by a powerful and complicate engine, which provide brilliant appearance and rich features, as a result, it would cost longer time to export so large quantity of data. For your requirement, we can use the following steps to improve the performance of exporting to excel:

1- Do not merge cells in a Tablix data region.

2- Consider using page breaks in the report.

3- Select a format that produces a smaller file, like CSV. Since it is just a flat text file, it has a fast write speed, we can export the report to csv format and then open it with excel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.