On Fri, 23 Jan 2015 03:38:19 -0800 (PST)
Joris Benschop <joris.bensc...@gmail.com> wrote:

> And to keep replying to myself:
> 
> This one is slow:
> x=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE MARKID= 
> %s",[u'TO1'])
> print x[0]
> 
> This one is fast:
> y=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE MARKID= 'TO1'")
> print y[0]
> 
> If I copy the table and make the  MARKID field in NVARCHAR2(20), then it 
> uses the index properly on both counts
> 
> So... so do I make django use ascii? is there a field type?

You could try explicit cast to VARCHAR2, not sure does that help at all:

x=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE MARKID=CAST(%s AS 
VARCHAR2)",[u'TO1'])


-- 
Jani Tiainen

-- 
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/20150123135923.25a181aa%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to