English

FAQ: Why do two queries appear for a single ArcSDE for SQL Server spatial query in the SQL Server Profiler?

Question

Why do two queries appear for a single ArcSDE for SQL Server spatial query in the SQL Server Profiler?

Answer

Two queries appear, yet only the second is executed. As can be seen in the SQL Server Profiler, the first query is parsed but not executed. This allows the software to check for the existence of the objects required for the query.

The second query is executed.

Example:

Code:
Query 1
---------------------------------------
select LAYERS.SDELOAD.STATESESRI.SHAPE from LAYERS.SDELOAD.STATESESRI

Query 2
---------------------------------------
SELECT S_.eminx,S_.eminy,S_.emaxx,S_.emaxy, SHAPE.fid F_fid,SHAPE.numofpts
F_numofpts,SHAPE.entity F_entity,SHAPE.points F_points FROM (SELECT DISTINCT
sp_fid,eminx,eminy,emaxx,emaxy FROM LAYERS.SDELOAD.s48 SP_ WHERE SP_.gx >= 7 AND
SP_.gx <= 8 AND SP_.gy >= 14 AND SP_.gy <= 15 AND SP_.eminx <= 85916428 AND SP_.eminy
<= 150327449 AND SP_.emaxx >= 74048077 AND SP_.emaxy >= 140847936 ) S_,
LAYERS.SDELOAD.f48 SHAPE WHERE S_.sp_fid = SHAPE.fid
---------------------------------------