mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Improve Query editor Read performance + cancel timely for large data (#2161)
This commit is contained in:
@@ -429,6 +429,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
do
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
columnSchemas.Add(reader.GetColumnSchema().ToArray());
|
||||
} while (reader.NextResult());
|
||||
}
|
||||
|
||||
@@ -88,11 +88,33 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token to use for cancelling a query</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Deprecated due to performance issues, please use Read() instead.")]
|
||||
public Task<bool> ReadAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return DbDataReader.ReadAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass-through to DbDataReader.Read()
|
||||
///
|
||||
/// ************** IMPORTANT ****************
|
||||
/// M.D.SqlClient's ReadAsync() implementation is not as
|
||||
/// performant as Read() and doesn't respect Cancellation Token
|
||||
/// due to long existing design issues like below:
|
||||
///
|
||||
/// https://github.com/dotnet/SqlClient/issues/593
|
||||
/// https://github.com/dotnet/SqlClient/issues/44
|
||||
///
|
||||
/// Until these issues are resolved, prefer using Sync APIs.
|
||||
/// *****************************************
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Read()
|
||||
{
|
||||
return DbDataReader.Read();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a value
|
||||
/// </summary>
|
||||
|
||||
@@ -396,8 +396,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
//
|
||||
availableTask = SendCurrentResults();
|
||||
|
||||
while (await dataReader.ReadAsync(cancellationToken))
|
||||
while (dataReader.Read())
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
fileOffsets.Add(totalBytesWritten);
|
||||
totalBytesWritten += fileWriter.WriteRow(dataReader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user