I've only 21 million rows in one of my tables and querying it is not a
problem. First check that suggested function based index, it might help
and you don't need to do anything.

istartswith uses "not so good" format. We have got around it using
additional field that is autopopulated, in your case it would be
"book_title_lcase" (or similiar), and then make it automatically
populate from title as lowercase. Now you can on add index to this
special lowercase field, and do query as:

books.objects.filter(book_title_lcase__startswith=request.GET['q'].lower())[:100]

It should hit index. Of course it adds some overhead when generating
objects.

On Tue, 2010-01-12 at 12:20 -0800, nameless wrote:
> The table is queried from ajax using an autocomplete field with this
> query in the views.py:
> 
> books.objects.filter(book_title__istartswith=request.GET['q'])[:100]
> 
> 
> 
> 
> ---------------
> 
> On Jan 12, 8:47 pm, Chris Czub <chris.c...@gmail.com> wrote:
> > It really depends on how you're selecting the data from the database. If
> > you're doing something that necessitates a full table scan(like in-DB ORDER
> > BY) it will slow you down considerably. If you're selecting one row from the
> > database by an indexed column, then the performance will be very fast and
> > there's no need to prematurely optimize.
> >
> > On Tue, Jan 12, 2010 at 2:25 PM, nameless <xsatelli...@gmail.com> wrote:
> > > My table with 4 milions of rows is queried often by ajax.
> > > So I think a performance problems ( I am using also index ).
> > > Ok now take a look at the contenttypes :)
> >
> > > ------------
> >
> > > On Jan 12, 8:15 pm, Tim <timster...@gmail.com> wrote:
> > > > As far as needing to split up the table into other tables, I'm not
> > > > sure. Whats wrong with having 4 million records in one table?
> >
> > > > But if you're going to do it, take a look at the contenttypes
> > > > framework and generic relations. It basically does what you're
> > > > describing:
> >
> > > >http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
> >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> >


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to