THank you all for your help there's a few things here: * This Oracle table is highly partitioned and optimized.There's indexes everywhere. There's two full time senior Oracle DBAs working on tuning this DB.So a return of 0.1 sec is not strange for this setup. (btw the DBAs are really impressed with the query setup by django, using bind vars and all)
* The query only returns a single record (as also seen from the Unique=True in the model definition). There is of course a unique index on the MARKID column. * If I run the exact query (included the nested _ROWNUM selection wrapper that Django does ) in cx_oracle or sqldev the query is very very fast. This is not a basic DB problem * If I monitor CPU, then executing the query does not result in any specific CPU load on the python process. Still, the query takes 50 seconds. And again, running this exact query in cx_Oracle with the same credentials is <0.1 sec to respond * connection from django to small tables is very fast! * there is no caching, as asking the result from django twice is also slow @james: two two subselects are generated by django The main problem seems to be that Django Oracle backend connects different than vanilla cx_Oracle. This is noticable from the fact that I cannot set the pooled connect as NAME, but I need to specify a server. in cx_Oracle, I need to specify the pool instead, or I get an error. Now the real weirdness is that this results in a different execution plan of the query. For cx_Oracle, the indexes are used properly. for Django it uses a full table scan. That of course takes a lot of time This is obviously partly oracles fault and we're looking into that. Howevr I still find it strange why I cannot use the pooled connection in django, or why django is connecting differently to the oracle db than cx_oracle (which I think is embedded in the oracle backend of django) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6f829cee-afd2-4514-baab-1d7a05d46159%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.