我有一些查询可以返回较大的结果集(> 10万行)。我需要向用户显示结果数,并且用户能够在我们的应用程序中浏览结果。但是,当页面上显示25时,没有人会翻阅100K项。因此,我希望将可分页结果的数量限制为5K,同时仍向用户显示结果的总数。
当然,我可以向数据库触发两个单独的查询:一个对所有结果进行计数,一个返回TOP(5000)。但是查询可能很昂贵。
是否存在将这两个查询合并为一个聪明的方法?下面的查询过于简化:
close all;
clc;
% read image
[embededimage_fname, image_pthname] = ...
uigetfile('*.jpg; *.png; *.tif; *.bmp', 'Select the Cover Image');
if (embededimage_fname ~= 0)
embedded_image = strcat(image_pthname, embededimage_fname);
embedded_image = double( rgb2gray( imread( embedded_image ) ) );
embedded_image = imresize(embedded_image, [512 512], 'bilinear');
else
return;
end
% read audio
[watermarkAudio_fname, watermark_pthname] = ...
uigetfile('*.wav', 'Select the Watermark audio');
if (watermarkAudio_fname ~= 0)
watermark_audio = strcat(watermark_pthname, watermarkAudio_fname);
[n, fs] = audioread(watermark_audio); % "n" is number of samples and fs is the sample rate
%watermark_audio = imresize(watermark_audio, [512 512], 'bilinear');
else
return;
end
imbin_seq = reshape(dec2bin(embedded_image, 8) - '0', 1, []);
% To calculate modified mean
na = 2^15;
n = n*na;
nLength = length(n);
modified_mean = mean(abs(n));
% Embedding Range
lmda = 2.4; %pick any value of lmda from the range (2.0, 2.5);
e_range = ceil(lmda * modified_mean);
%number of bins and Bin Width
h = histogram(n);
Bin_Num = h.NumBins();
Bin_Width = h.BinWidth();
有人可以帮忙吗?
答案 0 :(得分:0)
交叉加入
1602.720000
答案 1 :(得分:0)
您可以在下面尝试
func assetDownload(for item: DownloadItem) {
let asset = AVURLAsset(url: item.url)
asset.resourceLoader.preloadsEligibleContentKeys = true
asset.resourceLoader.setDelegate(self, queue: DispatchQueue.global(qos: .default))
// Create new AVAssetDownloadTask for the desired asset
guard let task = downloadSession.makeAssetDownloadTask(asset: asset,
assetTitle: item.title!,
assetArtworkData: data,
options: [AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: 2_787_000])
else {
status[item.url!] = .error
return
}
task.taskDescription = item.title!
// Start task and begin download
task.resume()
}
答案 2 :(得分:0)
您可以尝试以下查询:
SELECT TOP 5000 *,
COUNT(*)
OVER(ORDER BY (SELECT NULL))
FROM table
WHERE field = 1;