Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Doubts on a sqlite query
Doubts on a sqlite query [message #38612] Sat, 29 December 2012 08:53 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I have two tables, TEAMS with 120 records and PLAYERS with 600 records. Each team contains 5 players. After a sort I need to update a field of TEAMS and another of PLAYERS. Both fields are called N. To perform this task I use the following procedure
void vegadb::SetPairingNumbers(int n, int arr_N[], Vector<int> ids)
{ 	int i, id, idp, np=1;
	Sql sqlteam(sqliteVT);
	Sql sqlplayer(sqliteVT);
	Sql sqlp(sqliteVT);

 	for(i=0; i<n; i++) {
 	    id = arr_N[i];
	    sqlteam.Execute("update TEAMS set N=? where ID=?", i+1, ids[i]); 
            sqlplayer.Execute("SELECT ID FROM PLAYERS WHERE TEAM_ID=? ORDER BY BOARD ASC", id); //retrieve players of team id by boards
	    while (sqlplayer.Fetch()) {
			idp = (int) (sqlplayer[0]);
		        sqlp.Execute("update PLAYERS set N=? where ID=?", np++, idp); //set pairing number to the player idp
	    }      
	}
}

It works as expected. The problem is that it requires about 25 seconds on my notebook (intel celeron 1.70 GHz, 1Gb ram). It is not a monster machine but the number of records to be processed is not huge. Because I have not experience with sqlite I would like to know if this delay time is normal or maybe there is a faster way to write the query.

Thanks,
Luigi
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Use ctrls in another tab as detail problem
Next Topic: Can U++ communicate with a MSACCESS database?
Goto Forum:
  


Current Time: Fri Apr 26 17:19:20 CEST 2024

Total time taken to generate the page: 0.03366 seconds