On Feb 5, 12:36 pm, dan0 <dan.murie...@gmail.com> wrote:
> Hello,
>
> I am having an issue with my msyqld process responding to a query
> after a moderate period of inactivity. I'll issue a simple query such
> as "Person.objects.filter(name__icontains='Dan')", which would map to
> about 5000 entries in a table of roughly 200,000 rows, and see the
> mysqld process stall at 100% cpu load for upwards of 10 seconds.
>

Can you send in the table definition (usually DESCRIBE person_person;
in the database) and also the SQL that is being run (SELECT id FROM
person_person WHERE name like '%something%';)  as well as that SQL
with EXPLAIN put in front of it?

I presume there's a full text index on a text field and it's
rebuilding it on the fly when you do the icontains.

The correct solution is to make sure you need icontains instead of
istartswith.  Then, tighten up the column to be a CharField of 255
characters or less (if it's not already).  Then, start playing around
with getting more memory dedicated to the caches so that the 10 second
spinup happens less frequently.  Finally, you could consider
redesigning the models so that there is a Name lookup model for
finding the correct Person model (i.e. a model with just the name
field that is a foreign key to that).

Oh, once you drop into MySQL for testing, use "SELECT
SQL_NO_CACHE ..." so that you don't hit the cache.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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