ddb icon indicating copy to clipboard operation
ddb copied to clipboard

Slow down on x64 bit mode on Windows

Open bubnenkoff opened this issue 7 years ago • 1 comments

App do SELECT queries to PostgreSQL.

				string sql_distance = `SELECT osm_id, ST_DISTANCE(geometry::geography, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true) as dist FROM roads WHERE (SELECT bool_or(ST_Contains(geometry, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326))) FROM admin) ORDER BY geometry <-> ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326) LIMIT 1;`;

				writef("\nTrack %s. Total Points: %s. Processing", GPSAndSensor.gps, cargpspoints.count);
				Bar b = new Bar();
				b.message = { return "Calc Nearest Road Distance For Every Track Point"; };
				b.start();
				b.max = cargpspoints.count;

				foreach(i, cargpspoint; cargpspoints)
				{
					auto cmd_dist = new PGCommand(pgconnection, sql_distance.replace(`37.72308`, format("%f",cargpspoint.lon)).replace(`55.47957`, format("%f",cargpspoint.lat)));
					auto cmd_nearesPointOnRoad = new PGCommand(pgconnection, sql_nearesPointOnRoad.replace(`37.72308`, format("%f",cargpspoint.lon)).replace(`55.47957`, format("%f",cargpspoint.lat)));

					try
					{					
							auto TotalStartTime = MonoTime.currTime;

						auto nresult = cmd_dist.executeQuery();
						auto nanswer = nresult.array;
						nresult.close();
						if(nanswer.empty)
						{
						//	debug writefln(`%s.%s With Lon: %s Lat: %s outside from polygon "admin"`, config.mysqldbname, GPSAndSensor.gps, cargpspoint.lat, cargpspoint.lon);
							continue;
						}
						nearestroaddistance.id = nanswer.front[0].coerce!ulong;
						nearestroaddistance.distance = nanswer.front[1].coerce!ulong;

						auto TotalEndTime = MonoTime.currTime;
						auto totalDuration = TotalEndTime - TotalStartTime;
						writefln("\n [PG INFO] Calc Time: %s msecs", totalDuration.total!"msecs");
					}
					
					....

If I build it in 32-bit mode (default on Windows) the execution of queries take about 10-12 msecs. If I build it's with dub --arch=x86_64 the query is execution 130-150 msecs.

bubnenkoff avatar May 03 '17 08:05 bubnenkoff