Wednesday, November 14, 2012

Re: index_together...shouldn't indexes be created AFTER populating the table?

On Wed, 14 Nov 2012 15:42:55 -0500, Javier Guerra Giraldez
<javier@guerrag.com> declaimed the following in
gmane.comp.python.django.user:

> On Wed, Nov 14, 2012 at 3:14 PM, Chris Pagnutti
> <chris.pagnutti@gmail.com> wrote:
> > 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.
>
> AFAIK, this is an optimization advice applicable only for mostly-static tables.
>
Most of my books consider it an optimization for bulk-loading of
table data (say, recreating the tables from an SQL dump file (something
like the MySQL backup format -- a la:

--
-- Definition of table `conventions`
--

DROP TABLE IF EXISTS `conventions`;
CREATE TABLE `conventions` (
`ID` int(11) NOT NULL auto_increment,
`name` char(100) NOT NULL default '',
`URL` char(75) default NULL,
`sortdate` date NOT NULL default '0000-00-00',
`dates` char(50) NOT NULL default 'TBD',
`site` char(75) NOT NULL default 'TBD',
`notes` char(125) default NULL,
PRIMARY KEY (`ID`),
KEY `sortdate` (`sortdate`)
) ENGINE=MyISAM AUTO_INCREMENT=42 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `conventions`
--

/*!40000 ALTER TABLE `conventions` DISABLE KEYS */;
INSERT INTO `conventions`
(`ID`,`name`,`URL`,`sortdate`,`dates`,`site`,`notes`) VALUES
(28,'OklaCon X<br><i>It Came From Planet
X!/i>','http://www.oklacon.com/','2012-10-22','October 17 - 22,
2012','Watonga, OK','Roman Nose State Park'),
(2,'BayCon 2012','http://www.baycon.org/','2012-05-28','May 25 - 28,
2012','Santa Clara, CA',NULL),
(3,'AnthroCon 2012<br><i>A Midsummer Night\'s
Dream</i>','http://www.anthrocon.org/','2012-06-14','June 14 - 17,
2012','Pittsburgh, PA',NULL),

<snip>

(37,'Furry Connection
North','http://www.furryconnectionnorth.com/','2012-04-15','April 13 -
15, 2012','',NULL),
(41,'Wild Nights','http://www.wildnights.org/','2012-04-30','April 26 -
30, 2012','Robber\'s Cave State Park, OK','Another Camp Convention');
/*!40000 ALTER TABLE `conventions` ENABLE KEYS */;

(in which the /*!40000 ...*/ lines are conditional based upon the
version of the MySQL server executing the statements, and are used to
disable the indices at the start of the data load, then enable them at
the end)
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate