Hello Chris,

You are correct that creating indexes AFTER importing data is generally the
fastest approach, but there is currently no automated tool that will do
this all for you.

I actually did a blog post about this not so long ago, and it goes into
some detail;
http://blog.simplicitymedialtd.co.uk/?p=225

One way is to dump the table structures, create a clone of the table, use
SQLYog to compare the clone to the original and copy out only the INDEX
statements, then dump the data too.

But, if you're worried about insert performance then you'd want to think
about using a multi-threaded import approach, using tools such as mydumper
(slightly unstable) or splitting the dump into X number of files based on
line count. You'd also need to tinker with the innodb settings to ensure
the disks are being flushed to all the time, increasing the checkpoint age,
flush method etc.

I am by no means an expert on InnoDB (it's just been recently that I've
started to dive deep into it), and Google will almost certainly
offer infinitely better explanations on which parameters to tune etc.

Generally speaking, you only need to worry about this sort of thing once
you have passed a couple of million rows or approx 20GB datadir size.. The
amount of time this sort of thing consumes, not to mention the increased
risk of error or missing data, really is a pain..

The end conclusion I came to is that mydumper/mysqldump/mysqlimport all
suck, and there is a lot of room for improvement.. I'm hoping to build such
a tool one day :)

Cal

On Wed, Nov 14, 2012 at 8:14 PM, Chris Pagnutti <chris.pagnu...@gmail.com>wrote:

> Hi.  The new index_together feature is great, but I think it's best to
> create an index on a table AFTER the table is filled, and assuming there
> won't be many new inserts.  But in django, syncdb creates the index at the
> same time the table is created, and of course, the table is initially
> empty.  How does django deal with this?  Does it know to drop the index
> before inserting new records and re-create the index afterwards?
>
> If not, can I syncdb, drop the index manually in mysql, populate the
> table, then re-create the index manually (as long as I use the same index
> name that django chose)?  Will django be none-the-wiser if I do this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/gBx54Nzn5X8J.
> 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.
>

-- 
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