On Wednesday, April 24, 2013 at 18:31, Larry Martell wrote:
I changed it to delete one row at a time and it's taking 3 minutes.On Wed, Apr 24, 2013 at 6:38 PM, Setiaman Lee <setiaman.lee@gmail.com> wrote:Larry,Avoid to use IN clause. I'd say to insert the events you want to delete intothe temp table. You can put the session id or user id in temp table todifferentiate set of data from other users. Then do the delete by joiningthe temp table to the Event_Message_ldx table. your sql might look likethis:delete event_message_ldxfrom tempwhere event_message_ldx.event_id = temp.event_idand temp.userid = %sabove SQL can be executed in Django using RAW SQL. See the link below.https://docs.djangoproject.com/en/dev/topics/db/sql/Test the SQL in the MySQL workspace when it works then move the code to theDjango.Rgrds,Setiaman LeeOn Thu, Apr 25, 2013 at 8:12 AM, Larry Martell <larry.martell@gmail.com>wrote:I have a table that has 2.5 million rows and 9 columns that are allint except for 2 varchar(255) - i.e. not that big of a table. I amexecuting this statement:Event_Message_Idx.objects.filter(event_id__in=event_ids).delete()Where event_ids has around 1,500 items in it. There is an index onevent_id. This statement is taking 1 hour and 5 minutes to run. Thereis nothing else hitting the database at that time, and the machineit's running on is 97% idle and has plenty of free memory. This seemsextremely excessive to me. I would guess it's because of the inclause. Perhaps this is more of a MySQL question when a django one,but is there some better way to do a delete like this in django?--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 anemail to django-users+unsubscribe@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?hl=en.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 anemail to django-users+unsubscribe@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?hl=en.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+unsubscribe@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?hl=en.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+unsubscribe@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment