product_titleParts テーブルに継続的にデータを挿入するバックグラウンド ジョブ (C# コンソール アプリケーション) があります。このジョブは単純に、products テーブルから上位 100 個の製品を選択し、タイトルを部分に分割し、product_titleParts テーブルに挿入します。
このテーブルには、「TitlePart」というインデックス付きの列があります
一方、このテーブルから選択しようとすると、SQL クエリに時間がかかります。しばらくしてコンソール アプリを停止すると、クエリに 0 秒かかります。コンソール アプリを再度起動するとすぐに、応答しないクエリを再度選択します。
別のジョブが挿入されている間にテーブルから選択すると、速度が低下しますか? 選択時に nolock を使用していますが、役に立ちませんでした。
何か案が?
コンソール アプリのマイ コード:
if not exists(select 1 from product_titleParts where productid = @productid
and UserId = @userid and titlePart = @titlePart)
begin
insert into product_titleParts (userid, productid, titlePart)
VALUES (@userid, @productid, @titlePart)
end
私の選択コード:
select productid from product_titleParts
inner join products
on products.productid = product_titleParts.productid
where titlePart = @titlePart