I am a Permanent Member (or Community Ambassador) of the Drupal Association.UPDATE: Now as a shell script. You may have to update the MySQL user in the script. A file version of the script is attached. Download it, make it executable with chmod +x ./doublenodes, and then run it with ./doublenodes databasename
#!/bin/sh
mysql -u root -p -e "
INSERT INTO node (nid, vid) VALUES (NULL, -1);
SET @nid:= (SELECT MAX(nid) FROM node);
DELETE FROM node WHERE nid=@nid;
INSERT INTO node_revision (nid, vid) VALUES (@nid, '');
SET @vid:= (SELECT MAX(vid) FROM node_revision);
DELETE FROM node_revision WHERE vid=@vid;
INSERT INTO node
SELECT
NULL, @vid:=@vid+1,
type, language, title, uid, status, created, changed, comment, promote,
moderate, sticky, tnid, translate
FROM node;
INSERT INTO node_revision
SELECT
@nid:=@nid+1, NULL,
uid, title, body, teaser, log, timestamp, format
FROM node_revision;" $1
This will take the existing nodes in your db and copy them. If you have 10 to start with you will have 20 when you’re finished (and they’ll be copies of the first 10). This is good for populating a test database for performance testing where you want a lot of nodes. It is much faster than using Devel module’s generate (use that to get your first 1000 nodes or so, then use this query to double them, and double them again, and double them again, etc.) Note that this query doesn’t take CCK fields, uploaded files, comments, or taxonomy terms into account. Just the nodes.
It is important that Drupal get tested on databases with millions of nodes, and we need to share techniques like this, and possibly build extra infrastructure on Drupal.org, so that we can always test patches on large datasets.
PS: Is there a better way? How do you create databases with large data sets?
| Attachment | Size |
|---|---|
| doublenodes | 637 bytes |
Comments
community built script
The Drupal community could take what you have here, and gradually add to it. There's no reason not to have a few hundred lines of SQL which build a nice large database, including CCK fields, etc. This would be a standard test database that lots of people could use to compare behaviors and to optimize Drupal.
Indeed. But it has to work first.
Right now it gets mighty messed up - so hopefully I'll get it right, or someone will share a tip.
-Rob
Ok, works now.
-Rob
This is great. Thanks for
This is great. Thanks for posting the script online!
Ooooo very nice Blog..
Ooooo very nice Blog.. There's no reason not to have a few hundred lines of SQL which build a nice large database, including CCK fields, etc. This would be a standard sohbet test database that lots of people could use to compare behaviors and to optimize Drupal.
Post new comment