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 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 seconds.  What might be the problem?  My
> view function is below.  The 16 seconds is between cursor.execute and
> the if number_count[0][0] lines.  Thanks in advance for the help.
>
>     def get_number_of_notices(request, case_number):
>     from django.db import connections
>     try:
>     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+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/9aeb979c-4cce-4525-b813-2a35558cc62b%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/530E277E.9090202%40consbio.org.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to