Connection to gateway disconnects/connects because of query?

Hi, I have this very long query wherein i do

[code]SET @location = ‘2/12 Influent Wells - EW-12-05-180-M’;

SELECT @location AS LOCATION,
ROUND(sum(CASE WHEN t2.tagid = ‘2874’ THEN t2.floatvalue ELSE 0 END), 2) AS Meter_Reading,
ROUND(sum(CASE WHEN t2.tagid = ‘2734’ THEN t2.floatvalue ELSE 0 END), 2) AS GPM,
ROUND(sum(CASE WHEN t2.tagid = ‘2735’ THEN t2.floatvalue ELSE 0 END), 2) AS PSI,
ROUND(sum(CASE WHEN t2.tagid = ‘2736’ THEN t2.floatvalue ELSE 0 END), 2) AS DTW

FROM sqlt_data_2_2013_11 t2

INNER JOIN sqlth_te t1
ON t1.id = t2.tagid

WHERE t2.t_stamp = (SELECT MAX(t2.t_stamp)
FROM sqlt_data_2_2013_11 t2
WHERE t1.id = t2.tagid)

UNION ALL

SELECT ‘aes/fortord/site 12 slc/ew 12 06 180m/fiq’ AS LOCATION, /EW-12-06-180-M/
ROUND(sum(CASE WHEN t2.tagid = ‘2876’ THEN t2.floatvalue ELSE 0 END), 2) AS Meter_Reading,
ROUND(sum(CASE WHEN t2.tagid = ‘2743’ THEN t2.floatvalue ELSE 0 END), 2) AS GPM,
ROUND(sum(CASE WHEN t2.tagid = ‘2744’ THEN t2.floatvalue ELSE 0 END), 2) AS PSI,
ROUND(sum(CASE WHEN t2.tagid = ‘2742’ THEN t2.floatvalue ELSE 0 END), 2) AS DTW

FROM sqlt_data_2_2013_11 t2

INNER JOIN sqlth_te t1
ON t1.id = t2.tagid

WHERE t2.t_stamp = (SELECT MAX(t2.t_stamp)
FROM sqlt_data_2_2013_11 t2
WHERE t1.id = t2.tagid)

.
.
.
.
.
UNION ALL [/code]

I’ve noticed that since I started that sql query my connection to the gateway on the designer keeps disconnecting then connects back again and again.

Could it be because of this? Could it be something like query overload can that happen?

That is a distinct possibility. Do you get any errors in the Designer Console? Also, check the Gateway “Status > Database Connections” page and see what the stats for that connection are.