Awesome.  So I don't even have to declare the "index_together" in the 
django models?  I can just create them afterwards using pure mysql?

LOAD DATA INFILE is wicked fast!!! Thanks a ton for that one.

On Wednesday, November 14, 2012 4:36:49 PM UTC-5, Javier Guerra wrote:
>
> On Wed, Nov 14, 2012 at 3:49 PM, Chris Pagnutti 
> <chris.p...@gmail.com <javascript:>> wrote: 
> > Thanks for your reply.  The tables I'm dealing with are entirely static, 
> but 
> > some have many millions of records, which is why I want my indexes to 
> work 
> > as good as possible.  If I create my indexes manually AFTER populating 
> the 
> > tables, will queries made via the django db api on those tables use 
> those 
> > indexes properly? 
>
> of course.  although in your case what i'd do is: 
>
> - create the table with indexes 
> - suspend them 
> - bulk-insert the data 
> - resume (and rebuild) indexes 
>
> it's mostly the same as you propose, but i just like having as much of 
> the description as possible in the Django model declaration. 
>
> OTOH, if you insert millions of records offline, you might not want to 
> do it with Django.  MySQL has the LOAD DATA INFILE command and 
> mysqlimport utility, for exactly this scenario.  The docs also advice 
> using ALTER TABLE tbl_name DISABLE/ENABLE KEYS commands to 
> suspend/resume indexing. 
>
>
> > I'm thinking the answer is yes, since the use of the indexes happens at 
> the 
> > mysql level, and django just has to issue the select statement. 
>
> exactly.  the choice of indexing strategy is done by the RDMS on a 
> per-statement basis. 
>
> in fact, since the index_together wasn't available, i have done 
> exactly that (create without indexes, add them manually) more than 
> once.  usually i intend to add the ALTER TABLE commands to 
> sql/modelname.sql files as described in 
>
> https://docs.djangoproject.com/en/1.4/howto/initial-data/#providing-initial-sql-data
>  
>
>
> finally, the top authority in bulk-insertion of data to Django is Cal 
> Leeming (a regular on this list); i haven't been able to see his 
> webinar yet, but i'm sure he has lots of insight to add to this. 
>
> -- 
> Javier 
>

-- 
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/-/c8vfPRklE0kJ.
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