[23:14:31] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 1 [23:14:31] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "1"
[23:15:19] [DEBUG] cache_get_row_int - row: 660, field_idx: 15, connection: 1 [23:15:19] [DEBUG] CMySQLResult::GetRowData - row: '660', field: '15', data: "0"
mysql_tquery(server, "SELECT * FROM houses", "LoadHouses"); forward LoadHouses(); public LoadHouses() { new time = GetTickCount(); for(new b; b != 660; ++b) { House[b][hID] = cache_get_row_int(b, 0); House[b][hEnterX] = cache_get_row_float(b, 1); House[b][hEnterY] = cache_get_row_float(b, 2); House[b][hEnterZ] = cache_get_row_float(b, 3); House[b][hExitX] = cache_get_row_float(b, 4); House[b][hExitY] = cache_get_row_float(b, 5); House[b][hExitZ] = cache_get_row_float(b, 6); House[b][hCarX] = cache_get_row_float(b, 7); House[b][hCarY] = cache_get_row_float(b, 8); House[b][hCarZ] = cache_get_row_float(b, 9); House[b][hCarC] = cache_get_row_float(b, 10); cache_get_row(b, 11, House[b][hOwner]); House[b][hCost] = cache_get_row_int(b, 12); House[b][hInt] = cache_get_row_int(b, 13); House[b][hVW] = cache_get_row_int(b, 14); House[b][hLock] = cache_get_row_int(b, 15); } printf("%d ms",GetTickCount()-time); }
If you have 661 houses, the size of House array shouldn't be 800 but 670-675 and if needed more, changing the slot and restart the server wouldn't be a problem.
Anyway, as for your queries. Use cache_get_row/cache_get_row_* functions instead because retrieving the field's name requires more time that just a number. I still recommended using threaded queries (mysql_pquery is used for more than 1 connection) though. Last, more of a question. You do have an hID in your table so why you use "b" and start indexes from 1 when 0 can be used too? |
House[b][hID] = cache_get_row_int(h, 0); House[b][hEnterX] = cache_get_row_float(h,1); House[b][hEnterY] = cache_get_row_float(h,2); House[b][hEnterZ] = cache_get_row_float(h,3); House[b][hExitX] = cache_get_row_float(h,4); House[b][hExitY] = cache_get_row_float(h,5); House[b][hExitZ] = cache_get_row_float(h,6); House[b][hCarX] = cache_get_row_float(h,7); House[b][hCarY] = cache_get_row_float(h,8); House[b][hCarZ] = cache_get_row_float(h,9); House[b][hCarZ] = cache_get_row_float(h,10); cache_get_row(h,11,House[b][hOwner]); House[b][hCost] = cache_get_row_int(h,12); House[b][hInt] = cache_get_row_int(h,13); House[b][hVW] = cache_get_row_int(h,14); House[b][hLock] = cache_get_row_int(h,15);
[17:59:48] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 1 [17:59:48] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "1"
[18:00:35] [DEBUG] cache_get_row_int - row: 660, field_idx: 15, connection: 1 [18:00:35] [DEBUG] CMySQLResult::GetRowData - row: '660', field: '15', data: "0"
server = mysql_connect("", "", "", "",3306,true,5);
for(new i = 0; i < 661; i++) mysql_pquery(server, "SELECT * FROM houses", "LoadHouses","d",i);
forward LoadHouses(inter); public LoadHouses(inter) { new b = inter+1; House[b][hID] = cache_get_row_int(inter, 0); House[b][hEnterX] = cache_get_row_float(inter,1); House[b][hEnterY] = cache_get_row_float(inter,2); House[b][hEnterZ] = cache_get_row_float(inter,3); House[b][hExitX] = cache_get_row_float(inter,4); House[b][hExitY] = cache_get_row_float(inter,5); House[b][hExitZ] = cache_get_row_float(inter,6); House[b][hCarX] = cache_get_row_float(inter,7); House[b][hCarY] = cache_get_row_float(inter,8); House[b][hCarZ] = cache_get_row_float(inter,9); House[b][hCarZ] = cache_get_row_float(inter,10); cache_get_row(inter,11,House[b][hOwner]); House[b][hCost] = cache_get_row_int(inter,12); House[b][hInt] = cache_get_row_int(inter,13); House[b][hVW] = cache_get_row_int(inter,14); House[b][hLock] = cache_get_row_int(inter,15); }
mysql_tquery(server, "SELECT * FROM houses", "LoadHouses","");
forward LoadHouses();
public LoadHouses()
{
new rows = clamp(cache_get_row_count(server), 0, sizeof House - 1);
for(new b; b != rows; ++b)
{
House[b][hID] = cache_get_row_int(b, 0);
House[b][hEnterX] = cache_get_row_float(b, 1);
House[b][hEnterY] = cache_get_row_float(b, 2);
House[b][hEnterZ] = cache_get_row_float(b, 3);
House[b][hExitX] = cache_get_row_float(b, 4);
House[b][hExitY] = cache_get_row_float(b, 5);
House[b][hExitZ] = cache_get_row_float(b, 6);
House[b][hCarX] = cache_get_row_float(b, 7);
House[b][hCarY] = cache_get_row_float(b, 8);
House[b][hCarZ] = cache_get_row_float(b, 9);
House[b][hCarZ] = cache_get_row_float(b, 10);
cache_get_row(b, 11, House[b][hOwner]);
House[b][hCost] = cache_get_row_int(b, 12);
House[b][hInt] = cache_get_row_int(b, 13);
House[b][hVW] = cache_get_row_int(b, 14);
House[b][hLock] = cache_get_row_int(b, 15);
House[b][hKlass] = cache_get_row_int(b, 16);
}
}
It takes so much because you load 660 times the already loaded data. Do not use loop, the query itself selects ALL the data from the table.
EDIT: That's how it should be assuming hID is set to AUTO_INCREMENT. pawn Код:
pawn Код:
|
for(new i = 0; i < 661; i++) mysql_pquery(server, "SELECT * FROM houses", "LoadHouses","d",i);
mysql_tquery(server, "SELECT * FROM houses", "LoadHouses","");
Do you still use this:
PHP код:
PHP код:
For the second, this should be loaded within one second as you only send 1 query instead of 662 queries. The query already loads ALL houses from the table at once, there is no need to loop through each house separately and send a query for each house. |
mysql_tquery(server, "SELECT * FROM houses", "LoadHouses");
forward LoadHouses(); public LoadHouses() { new time = GetTickCount(); for(new b; b != 660; ++b) { House[b][hID] = cache_get_row_int(b, 0); House[b][hEnterX] = cache_get_row_float(b, 1); House[b][hEnterY] = cache_get_row_float(b, 2); House[b][hEnterZ] = cache_get_row_float(b, 3); House[b][hExitX] = cache_get_row_float(b, 4); House[b][hExitY] = cache_get_row_float(b, 5); House[b][hExitZ] = cache_get_row_float(b, 6); House[b][hCarX] = cache_get_row_float(b, 7); House[b][hCarY] = cache_get_row_float(b, 8); House[b][hCarZ] = cache_get_row_float(b, 9); House[b][hCarC] = cache_get_row_float(b, 10); cache_get_row(b, 11, House[b][hOwner]); House[b][hCost] = cache_get_row_int(b, 12); House[b][hInt] = cache_get_row_int(b, 13); House[b][hVW] = cache_get_row_int(b, 14); House[b][hLock] = cache_get_row_int(b, 15); } printf("%d ms",GetTickCount()-time); }]