def get_number_of_notices(request, case_number):from django.db import connectionstry:cursor = connections['landmgm'].cursor()cursor.execute('SELECT count(1) from (SELECT DISTINCT RECORDNUMB FROM NOTICED_PARCELS WHERE CASE_NUMBER = %s AND RECORDNUMB > 0 UNION \SELECT DISTINCT RECORDNUMB FROM CONDONOTICE WHERE CASE_NUMBER = %s AND RECORDNUMB > 0)', [case_number, case_number])number_count = cursor.fetchone()if number_count[0][0] <= 0:msg = json.dumps('{"msg":"Notification has not been run for this case", "number_notified":"0", "result":"Fail"}')return HttpResponse(msg, content_type='application/json')else:msg = json.dumps('{"msg":"Notification has been run for this case", "number_notified":"' + str(number_count[0][0]) + '", "result":"Success"}')return HttpResponse(msg, content_type='application/json')except:msg = json.dumps('{"msg":"An error was encountered while checking this case number. Please contact GIS Staff.", "result":"Error"}')return HttpResponse(msg, content_type='application/json')
--
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...@googlegroups.com.
To post to this group, send email to django...@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/9aeb979c-4cce-4525-b813-2a35558cc62b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
cnxn = cx_Oracle.connect('notification/notifydev@landmgm')cursor = cx_Oracle.Cursor(cnxn) #connections['landtest_11'].cursor()print datetime.datetime.now()cursor.execute('SELECT count(1) from (SELECT DISTINCT RECORDNUMB FROM DEVGIS.NOTICED_PARCELS WHERE CASE_NUMBER = &s AND RECORDNUMB > 0 UNION \SELECT DISTINCT RECORDNUMB FROM DEVGIS.CONDONOTICE WHERE CASE_NUMBER = &s AND RECORDNUMB > 0)', [case_number, case_number])print datetime.datetime.now()number_count = cursor.fetchone()
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, 2014 3:49:47 PM UTC-6, Shawn H wrote: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 <shawn....@gmail.com> 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 development web server as well as my production
> apache linux box, and it always takes much longer running via django.
>
>
If you write a standard python program, ie not using django, but still
using whatever oracle DB adapter Django uses, that connects to your
oracle server and executes the query, is it still slow?
IE is the problem something django does, or how the adapter works.
Cheers
Tom
--
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...@googlegroups.com.
To post to this group, send email to django...@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/c4ff4ee0-43b8-4d1f-9ef0-6ef93546dcad%40googlegroups.com.
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 know if you see improvements in speed from the SQLPlus, and subsequently Django?
SELECT count(1) from (SELECT RECORDNUMB FROM YOURRECORDTABLEwhere RECORDNUMB IN(SELECT RECORDNUMFROM NOTICED_PARCELSWHERE CASE_NUMBER = %s AND RECORDNUMB > 0
UNION count(1)
--
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...@googlegroups.com.
To post to this group, send email to django...@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/7b3fd61c-f2de-4e29-87b8-1637ce1f5169%40googlegroups.com.