-
May 24th, 2004, 10:02 AM
#1
Fast Query
Is possible make faster query ?
I have follow code and this is slow.
Different system ?
CString Day= "20040524";
CString Period1 ="Other1";
CString Period2 ="Other2";
m_pSet->Close();
m_pSet->m_strFilter.Format(" COL1 > '%s' AND COL2 <> '%s' AND COL3 <> '%s'" ,Day,Period1 ,Period2);
m_pSet->Open();
int recCount = m_pSet->GetRecordCount();
if (recCount == 0){
m_pSet->Close();
m_pSet->m_strFilter = "";
m_pSet->Open();
nFields = 0;
m_list.DeleteAllItems();}
else { int ii = 0;
}
while ( !m_pSet->IsEOF( ) ){
m_pSet->GetFieldValue(("COL1"), CDay);
m_list.InsertItem(ii, CDay);
m_pSet->GetFieldValue(("COL2"), CPeriod1);
m_list.SetItemText(ii, 1, CPeriod1);
m_pSet->GetFieldValue(("COL3"), CPeriod2);
m_list.SetItemText(ii, 2, CPeriod2);
m_pSet->GetFieldValue(("COL4"), CPeriod3);
m_list.SetItemText(ii, 3, CPeriod3);
UpdateData(FALSE);
m_pSet->MoveNext();}
-
May 24th, 2004, 10:12 AM
#2
If you want any type of performance, do NOT use alpha column lookups within the loop....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 24th, 2004, 11:16 AM
#3
i'm stupid, could you elaborate ?
-
May 24th, 2004, 12:02 PM
#4
Documentation for GetRecordCount says you have to actually read the records. Just calling it after an open won't work. Test for IsEOF() instead. Other than that, just make sure the fields you're querying are indexed. Also, if it's a big table, a dynaset may run quicker than a snapshot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|