Do you fetch all the results when running the query directly against 
Oracle? Many Oracle SQL clients do not fetch all the results, instead they 
fetch just the top 100 or so rows.

 - Anssi

On Thursday, January 22, 2015 at 5:32:36 PM UTC+2, Joris Benschop wrote:
>
> Dear List,
>
> I'm trying to run a simple select on a very large Oracle table (1500 
> million records). 
>
> I create a standard django model:
> ------------------
> class Marker(models.Model):
>     marker_id = SYSGUID16Field(primary_key=True)  # This field type is a 
> guess.
>     markid = models.CharField(unique=True, max_length=20, blank=True)
>     crop = models.ForeignKey("variantdb_admin.Crop", blank=True, null=True)
>     insid = models.CharField(max_length=5, blank=True)
>     insdate = models.DateTimeField(blank=True, null=True)
>
>     class Meta:
>         managed = False
>         db_table = "prod_schema"."marker"
> ------------------
>
> then simply run:
> >>> x = Marker.objects.filter(markid = 'TO11')
> >>> print x
>
> in debugger, this basically creates the following simple query:
> DEBUG (44.120) QUERY = u'SELECT "PROD_SCHEMA"."MARKER"."MARKER_ID", 
> "PROD_SCHEMA"."MARKER"."MARKID", "PROD_SCHEMA"."MARKER"."CROP_ID", 
> "PROD_SCHEMA"."MARKER"."INSID", "PROD_SCHEMA"."MARKER"."INSDATE" FROM 
> "PROD_SCHEMA"."MARKER" WHERE "PROD_SCHEMA"."MARKER"."MARKID" = :arg0' - 
> PARAMS = (u'TO11',); args=('TO11',)
>
> As you see, in Django this takes 44 seconds to run. 
> If I run this exact same query with cx_oracle directly the response time = 
> < 0.1sec.
>
> For small tables the performance of django is quite good, so it almost 
> seems like django tries to do a count on the table before runnign the query 
> or something. Any suggestions on how I can make this lookup faster?
>
> thanks
> joris
>
>
>
>

-- 
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/e39a3ba6-2944-4070-8150-bbcb4b115cfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to