Fast Sensor Object Counting With Arduino
I think it's your code that's causing the slowdown, especially that while loop (already nested within loop()). It could also be the ethernet but I doubt it.

Try this. Use a flag to determine whether or not an object was previously detected so you don't have to write a nested while loop.

int objDetected = 0;    // flag
int detection = 1020;   // detection threshold

void loop()
{
    dummy=0;  
    dummy=SensorControl2();
    if (dummy&gt;0) {
    //Send data to SQL
    }
}

int SensorControl2()
{
sensorValue = analogRead(sensorPin);

if (sensorValue &gt; detection) {
    // Sensor senses something for the first time, sets flag
    if (objDetected == 0) {
        Serial.println("object detected");
        objDetected = 1;
        return MachineID;
    }
    // Sensor senses something but object is still there
    else {
        return 0;
    }
}
// There is no object detected, reset the flag
else {
    objDetected = 0;
}