Re: Terrible performance when dropping into raw SQL Oracle

2014-03-05 Thread junctionapps
You understood it exactly. I've been cleaning up some old SQL statements (outside of use in Django) and have seen some real benefits of restructuring to reduce execution times. Unnecessary overuse of 'distinct' was a favourite of someone in my organization a few years back. Good luck! On Wednes

Re: Terrible performance when dropping into raw SQL Oracle

2014-03-05 Thread Kurtis Mullins
Sort of off-topic as I don't have anything constructive to add to help fix your problem but I recommend not running complex (long-running) queries directly in Django views. Perhaps use Celery. I know this doesn't solve your problem (although it might help a bit if Django's environment is causing i

Re: Terrible performance when dropping into raw SQL Oracle

2014-03-05 Thread Shawn H
I can't do that, as your assumption is incorrect. I don't have a table that holds recordnumb as a unique value. Each recordnumb occurs many times, and occurs many times per case number, by design. The number is used to identify unique ownership among many properties for a particular case - eac

Re: Terrible performance when dropping into raw SQL Oracle

2014-03-03 Thread junctionapps
Hey Shawn, would you do me a favour and try something a query with a implicit distinct like the following substituting YOURRECORDTABLE for whatever table holds your recordnumb as a unique value (I'm making a large assumption you have a table where each recordnum occurs once). Could you let me k

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-27 Thread Shawn H
The cursor.execute specifically. I'm printing a timestamp immediately before and immediately after that line. I'm positive it is ONLY the query that takes 16 seconds, whether using django.cursor or a cx_Oracle cursor. On Thursday, February 27, 2014 9:27:48 AM UTC-6, Scott Anderson wrote: > > A

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-27 Thread Scott Anderson
Are you timing the query in the view specifically, or the entire view? That is, do you know for sure that it is *only* the query that is taking 16 seconds and not the rest of the view? -scott On Wednesday, February 26, 2014 5:53:15 PM UTC-5, Shawn H wrote: > > I said that before testing it. Th

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Thomas Lockhart
On 2/26/14 2:41 PM, Shawn H wrote: Because this worked so well, I've gone directly to cx_Oracle in my django view and used that to get the result in the 4 seconds. There is definitely a problem with the Django implementation - I wonder if perhaps the indexes on the tables aren't being used pro

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Shawn H
I said that before testing it. The exact same code using cx_Oracle takes ~4 seconds outside of the django environment, but still takes ~16 seconds when running in the django view. What the heck is going on? Updated portion of code below cnxn = cx_Oracle.connect('notification/notifydev@landmg

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Shawn H
Because this worked so well, I've gone directly to cx_Oracle in my django view and used that to get the result in the 4 seconds. There is definitely a problem with the Django implementation - I wonder if perhaps the indexes on the tables aren't being used properly. On Wednesday, February 26, 2

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Shawn H
3.8 seconds. It seems to be django, not cx_Oracle. On Wednesday, February 26, 2014 2:50:58 PM UTC-6, Shawn H wrote: > > Good idea. I'll try that and report back > > On Wednesday, February 26, 2014 1:22:52 PM UTC-6, Tom Evans wrote: >> >> On Wed, Feb 26, 2014 at 6:16 PM, Shawn H wrote: >> > Yes

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Shawn H
Good idea. I'll try that and report back On Wednesday, February 26, 2014 1:22:52 PM UTC-6, Tom Evans wrote: > > On Wed, Feb 26, 2014 at 6:16 PM, Shawn H > > wrote: > > Yes. I've tested with several case numbers, and I'm using a similar > > parameterized approach in my gui Oracle client as wel

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Tom Evans
On Wed, Feb 26, 2014 at 6:16 PM, Shawn H wrote: > Yes. I've tested with several case numbers, and I'm using a similar > parameterized approach in my gui Oracle client as well, with the same > results. It's always about 3 to 4 times slower running via django. I've > tried it both on my local dev

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Shawn H
Yes. I've tested with several case numbers, and I'm using a similar parameterized approach in my gui Oracle client as well, with the same results. It's always about 3 to 4 times slower running via django. I've tried it both on my local development web server as well as my production apache l

Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Nikolas Stevenson-Molnar
Is the case number the same when you run the query in SqlPlus as when you run it in Django? In other words, are you certain the query is /exactly/ the same? _Nik On 2/25/2014 2:09 PM, Shawn H wrote: > I've an app that has to drop into raw sql to run a query in a > different Oracle database. The

Terrible performance when dropping into raw SQL Oracle

2014-02-25 Thread Shawn H
I've an app that has to drop into raw sql to run a query in a different Oracle database. The ORM isn't involved as I'm trying to get a count of rows that meet specific criteria to return that count via an AJAX call. Running the identical query in SqlPlus takes ~4 seconds. Django takes ~16 se