데이터를 가져 오려고하는 데이터베이스에는 약 50,000 개의 문서가 있습니다. 현재 iOS 또는 Android 기기가 조회시 휴대 기기에 데이터를 쿼리하고 표시하는 데 약 90 초가 걸립니다. 내 코드는 아래에 게시됩니다. 이 속도를 높이기 위해 다르게 할 수있는 것이 있습니까? 모든 팁 주셔서 감사.보기 데이터 가져 오기 속도 향상?
function updateAllPoliciesTable() {
try {
var db = Alloy.Globals.dbPolicyInquiry;
var view = db.getView("AllRecordsByInsured");
var vec = view.getAllEntriesBySQL("Agent like ? OR MasterAgent like ?", [Ti.App.agentNumber, Ti.App.agentNumber], true);
var ve = vec.getFirstEntry();
var data = [];
while (ve) {
var unid = ve.getColumnValue("id");
var row = Ti.UI.createTableViewRow({
unid : unid,
height: '45dp',
rowData: ve.getColumnValue("Insured") + " " + ve.getColumnValue("PolicyNumber")
});
var viewLabel = Ti.UI.createLabel({
color : '#333',
font : {
fontSize : '16dp'
},
text: toTitleCase(ve.getColumnValue("Insured")) + " " + ve.getColumnValue("PolicyNumber"),
left: '10dp'
});
row.add(viewLabel);
data.push(row);
ve = vec.getNextEntry();
}
//Ti.API.log("# of policies= " + data.length);
if(data.length == 0) {
var row = Ti.UI.createTableViewRow({
title : "No policies found"
});
data.push(row);
}
$.AllPoliciesTable.setData(data);
Alloy.Globals.refreshAllPolicies = false;
Alloy.Globals.loading.hide();
} catch (e) {
DTG.exception("updateAllPoliciesTable -> ", e);
}
}
쿼리를 반환하는 데 걸리는 시간을 계산할 수 있습니까? UI 또는 DB에 중단이 있습니까? 'like' 쿼리를 사용해야합니까? –
요시아는 좋은 지적입니다. 느린 화면으로의 데이터 검색 또는 데이터 검색입니까? 다른 사용자가 제안한대로 색인을 작성해야 할 수도 있고 행 코드를 최적화해야 할 수도 있습니다. TableViewRow의 className을 조사하십시오. – Martin