Hi,

I have a query which is running slower than I think it should. It takes about 6 seconds to complete first time, then 500ms each subsequent time and returns about 100 rows. The table has about 300,000 rows in it.

I can't figure out how to tell if it is using an index or not (or the right index) so I was hoping someone could help me. I have an index on the column SAMPLEDATETIME, so I would have thought the query would run very quickly and just use that index. The "Explain" command only tells me about the index used for the join, but doesn't tell me about the where clause.


EXPLAIN SELECT "T132"."SITEID", "T131"."SAMPLEDATETIME", "T131"."COLLECTEDBY" FROM "DB"."PUBLIC"."SAMPLE" AS "T131", "DB"."PUBLIC"."SAMPLEPOINT" AS "T132" WHERE "T131"."SAMPLEPOINTID" = "T132"."SAMPLEPOINTID" AND "T131"."SAMPLEDATETIME" >= {D '2010-01-01' } ORDER BY "T131"."SAMPLEDATETIME" DESC, "T131"."COLLECTEDBY" ASC


SELECT T132.SITEID, T131.SAMPLEDATETIME, T131.COLLECTEDBYFROM PUBLIC.SAMPLEPOINT T132 /* PUBLIC.SAMPLEPOINT_DATA */INNER JOIN PUBLIC.SAMPLE T131 /* PUBLIC.SAMPLE_SAMPLEPOINTID_SAMPLEPOINT_SAMPLEPOINTID_INDEX_9: SAMPLEPOINTID = T132.SAMPLEPOINTID */ ON 1=1WHERE (T131.SAMPLEDATETIME >= TIMESTAMP '2010-01-01 00:00:00.0') AND (T131.SAMPLEPOINTID = T132.SAMPLEPOINTID)ORDER BY 2 DESC, 3

Many Thanks,

Ryan

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to h2-datab...@googlegroups.com.
To unsubscribe from this group, send email to 
h2-database+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to