0

I'm trying to run a query against an Oracle database. The first time I run it, it takes about 7 seconds. The second time I try to run it, it doesn't seem to ever actually complete. This is in both Oracle SQL developer and in the application I am developing (using JDBC Oracle Thin).

If I add a space to the query somewhere where I haven't done before, the query takes 7 seconds again.

I'm assuming this is because Oracle thinks it is a new query. Is there any way I can force Oracle to treat a query as one it hasn't seen before, even though it has?

user1838292
  • 21
  • 1
  • 4
  • 1
    Can you give any detail about query(insert/select/ is there Joins etc.) and Oracle version? Usually Oracle keeps query results in memory so if you send same query again, it should return faster, not slower. – Canburak Tümer Feb 26 '13 at 13:01
  • 3
    This is not usual. Normally a query runs slowest the first time; the database has to parse the query, etc. Also on subsequent runs the data is more likely to be cached in the database and/or the OS. So what you need to provide *way more detail* about what you're doing, because without that we cannot spot what is different about your situation from every other Oracle instance which will explain your anomalous results. – APC Feb 26 '13 at 13:03
  • Is this a heavily loaded production server? Just wondered if it is getting thrown out the cache. Maybe speak to the DBA to see if there is a hint that could be applied to increase the cache retention time on a per query basis. Alternatively, the cache size may need adjusting. – Robbie Dee Feb 26 '13 at 13:25
  • Could you please give us more information like: The server that the Oracle runs on, the query itself, an explain plan if possible and definitions of the tables you're using. By definitions I mean, the indexes, PK, FK, restrictions etc. – g00dy Feb 27 '13 at 08:14

0 Answers0