-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SQL performance option #4785
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
if (inputResource is not Parameters) | ||
{ | ||
throw new RequestNotValidException(string.Format(Resources.UnsupportedResourceType, inputResource.GetType().ToString())); | ||
throw new RequestNotValidException(string.Format(Api.Resources.UnsupportedResourceType, inputResource.GetType().ToString())); |
Check notice
Code scanning / CodeQL
Redundant ToString() call Note
if (string.Equals(useQueryCache, "true", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return await SearchImpl(sqlSearchOptions, true, cancellationToken); | ||
} | ||
else if (string.Equals(useQueryCache, "false", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return await SearchImpl(sqlSearchOptions, false, cancellationToken); | ||
} | ||
else if (string.Equals(useQueryCache, "both", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
_logger.LogInformation("Running search with and without query cache."); | ||
var stopwatch = Stopwatch.StartNew(); | ||
|
||
using var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); | ||
var token = tokenSource.Token; | ||
|
||
var tryWithQueryCache = SearchImpl(sqlSearchOptions, true, token); | ||
var tryWithoutQueryCache = SearchImpl(sqlSearchOptions, false, token); | ||
|
||
var result = await Task.WhenAny(tryWithQueryCache, tryWithoutQueryCache); | ||
await tokenSource.CancelAsync(); | ||
|
||
_logger.LogInformation("First search completed in {ElapsedMilliseconds}ms, query cache enabled: {QueryCacheEnabled}.", stopwatch.ElapsedMilliseconds, result == tryWithQueryCache); | ||
return await result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to expose this on such a granular level?
{ | ||
return await SearchImpl(sqlSearchOptions, false, cancellationToken); | ||
} | ||
else if (string.Equals(useQueryCache, "both", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an enum?
I think the description is now out of date for "x-ms-query-latency-over-efficiency" |
Description
Adds support for the x-ms-query-latency-over-efficiency header for Gen2. This makes SQL searches run two searches in parallel, with and without query caching. This helps in situations where one or the other will perform better than the other, but it doubles the load on the DB.
Related issues
Addresses User Story 137387: DDMS: SQL search with and without cache
Testing
Describe how this change was tested.
FHIR Team Checklist
Semver Change (docs)
Patch