patrussell
Technical User
I have the following RPC showing in my SQL trace and am looking for help on how to optimize the query shown. I have several queries that are similar to this on and no control over the structure of the query as it is run from an external data trending software.
The timestamps in the tables are anything from 1 second up and each table has between several hundred thousand to several million rows.
I've looked at the SQL performance site but I can't see anything that would apply to my situation. Putting a key on a 1 second timestamp doesn't seem like it would help much...
Thanks for any help that can be given.
Pat Russell
Code:
declare @P1 int
set @P1=1
exec sp_prepexec @P1 output, NULL, N'SELECT "FURBURNERS_ARC"."timestamp" AS "timestamp" , "FURBURNERS_ARC"."FCATBURNER5_VAL0" AS "FCATBURNER5_VAL0" FROM "FURBURNERS_ARC" WHERE "FURBURNERS_ARC"."timestamp">=(select min("tb"."timestamp") as "timestamp" from (select max("FURBURNERS_ARC"."timestamp") as "timestamp" from "FURBURNERS_ARC" where "timestamp"<{ts ''2003-06-16 11:11:01''} UNION select min("timestamp") FROM "FURBURNERS_ARC" WHERE "timestamp">={ts ''2003-06-16 11:11:01''} ) "tb" WHERE NOT "timestamp" IS NULL) and "FURBURNERS_ARC"."timestamp"<=(select max("tb"."timestamp") as "timestamp" from (select min("FURBURNERS_ARC"."timestamp") as "timestamp" from "FURBURNERS_ARC" where "timestamp">{ts ''2003-06-16 12:11:01''} UNION select max("timestamp") FROM "FURBURNERS_ARC" WHERE "timestamp"<={ts ''2003-06-16 12:11:01''} ) "tb" where not "timestamp" is null) ORDER BY "FURBURNERS_ARC"."timestamp"'
select @P1
The timestamps in the tables are anything from 1 second up and each table has between several hundred thousand to several million rows.
I've looked at the SQL performance site but I can't see anything that would apply to my situation. Putting a key on a 1 second timestamp doesn't seem like it would help much...
Thanks for any help that can be given.
Pat Russell