[英]Speed issues fetching Thousands of rows in a SQLCE database
首先快速免責聲明:關於數據庫,我是一個完全菜鳥。 我知道如何構成一個SQL查詢,並且...好吧,差不多了-我認為這樣就足夠了。 性能優化將在稍后發布。
“后來”到了。 我需要你的幫助。
我正在對新聞文章進行NLP處理。 文章取自Internet並存儲在數據庫中。 用戶給了我一個輸入時期來進行分析,我提出了這個時期內的所有文章,對其進行了分析並顯示了一些圖表作為回報。 我目前對此還比較幼稚-我不限制返回的文章數量。 每天大約250篇文章* 6個月是45,000條記錄,數量相當可觀。
我的讀取性能中等。 我正在使用C#+ SQLCE(最簡單的數據庫開始,沒有設置成本)。 我嘗試索引數據庫無濟於事。 我懷疑問題來自於
我完全瘋狂地嘗試一次調用就獲取數千條記錄嗎? SQLCE是一個愚蠢的選擇嗎? 我基本上需要有關此的實用建議。 另外,如果您可以為我提供解決我的問題的替代方案,那就更好了。
您的幫助對我很有價值-預先感謝!
編輯 -以下是我用來獲取文章的命令:
using (SqlCeCommand com1 = new SqlCeCommand(mySqlRequestString, myConnectionString))
{
SqlCeResultSet res = com1.ExecuteResultSet(ResultSetOptions.Scrollable);
if (res.HasRows)
{
//Use the get ordinal method so we don’t have to worry about remembering what order our SQL put the field names in.
int ordGuid = res.GetOrdinal("Id"); int ordUrl = res.GetOrdinal("Url"); int ordPublicationDate = res.GetOrdinal("PublicationDate");
int ordTitle = res.GetOrdinal("Title"); int ordContent = res.GetOrdinal("Content"); int ordSource = res.GetOrdinal("Source");
int ordAuthor = res.GetOrdinal("Author"); int ordComputedKeywords = res.GetOrdinal("ComputedKeywords"); int ordComputedKeywordsDate = res.GetOrdinal("ComputedKeywordsDate");
//Get all the Articles
List<Article> articles = new List<Article>();
if (res.ReadFirst())
{
// Read the first record and get its data
res.ReadFirst();
Constants.Sources src = (Constants.Sources)Enum.Parse(typeof(Constants.Sources), res.GetString(ordSource));
string[] computedKeywords = res.IsDBNull(ordComputedKeywords)?new string[]{}: res.GetString(ordComputedKeywords).Split(',').ToArray();
DateTime computedKeywordsDate = res.IsDBNull(ordComputedKeywordsDate) ? new DateTime() : res.GetDateTime(ordComputedKeywordsDate);
articles.Add(new Article(res.GetGuid(ordGuid), new Uri(res.GetString(ordUrl)), res.GetDateTime(ordPublicationDate), res.GetString(ordTitle), res.GetString(ordContent), src, res.GetString(ordAuthor), computedKeywords, computedKeywordsDate));
}
// Read the remaining records
while (res.Read())
{
Constants.Sources src = (Constants.Sources)Enum.Parse(typeof(Constants.Sources), res.GetString(ordSource));
string[] computedKeywords = res.IsDBNull(ordComputedKeywords) ? new string[] { } : res.GetString(ordComputedKeywords).Split(',').ToArray();
DateTime computedKeywordsDate = res.IsDBNull(ordComputedKeywordsDate) ? new DateTime() : res.GetDateTime(ordComputedKeywordsDate);
articles.Add(new Article(res.GetGuid(ordGuid), new Uri(res.GetString(ordUrl)), res.GetDateTime(ordPublicationDate), res.GetString(ordTitle), res.GetString(ordContent), src, res.GetString(ordAuthor), computedKeywords, computedKeywordsDate));
}
return articles.ToArray();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.