1 | <?php |
---|
2 | require __DIR__ . '/src/wp-load.php'; |
---|
3 | |
---|
4 | $test_table = 'j5test_signups'; |
---|
5 | |
---|
6 | echo "- Creating $test_table table ... "; |
---|
7 | $start = microtime( TRUE ); |
---|
8 | $wpdb->query( " |
---|
9 | CREATE TABLE $test_table ( |
---|
10 | domain varchar(200) NOT NULL default '', |
---|
11 | path varchar(100) NOT NULL default '', |
---|
12 | title longtext NOT NULL, |
---|
13 | user_login varchar(60) NOT NULL default '', |
---|
14 | user_email varchar(100) NOT NULL default '', |
---|
15 | registered datetime NOT NULL default '0000-00-00 00:00:00', |
---|
16 | activated datetime NOT NULL default '0000-00-00 00:00:00', |
---|
17 | active tinyint(1) NOT NULL default '0', |
---|
18 | activation_key varchar(50) NOT NULL default '', |
---|
19 | meta longtext, |
---|
20 | KEY activation_key (activation_key), |
---|
21 | KEY domain (domain) |
---|
22 | ); |
---|
23 | " ); |
---|
24 | $stop = microtime( TRUE ); |
---|
25 | $time = number_format( $stop - $start, 2 ); |
---|
26 | echo " $time seconds\n"; |
---|
27 | |
---|
28 | echo "- Adding 100,000 rows to $test_table ... "; |
---|
29 | $start = microtime( TRUE ); |
---|
30 | for ( $i = 0; $i < 100000; $i++ ) { |
---|
31 | $wpdb->insert( |
---|
32 | $test_table, |
---|
33 | array( |
---|
34 | 'domain' => 'example.com', |
---|
35 | 'path' => '/testme/', |
---|
36 | 'title' => 'WP test', |
---|
37 | 'user_login' => 'exampleusername', |
---|
38 | 'user_email' => 'example@example.com', |
---|
39 | 'registered' => '2013-01-01 11:11:11', |
---|
40 | 'activated' => '2013-02-02 02:02:02', |
---|
41 | 'active' => 1, |
---|
42 | 'activation_key' => 'notreallyrandomjustfiller', |
---|
43 | 'meta' => 'be nice, help others, find a friend' |
---|
44 | ), |
---|
45 | array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s' ) |
---|
46 | ); |
---|
47 | } |
---|
48 | $stop = microtime( TRUE ); |
---|
49 | $time = number_format( $stop - $start, 2 ); |
---|
50 | echo " $time seconds\n"; |
---|
51 | |
---|
52 | echo "- Adding signup_id column ( PK ) to $test_table ... "; |
---|
53 | $start = microtime( TRUE ); |
---|
54 | $wpdb->query( " |
---|
55 | ALTER TABLE $test_table |
---|
56 | ADD signup_id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST |
---|
57 | " ); |
---|
58 | $stop = microtime( TRUE ); |
---|
59 | $time = number_format( $stop - $start, 2 ); |
---|
60 | echo " $time seconds\n"; |
---|
61 | |
---|
62 | echo "- Dropping key on domain column ... "; |
---|
63 | $start = microtime( TRUE ); |
---|
64 | $wpdb->query( " |
---|
65 | ALTER TABLE $test_table |
---|
66 | DROP INDEX domain |
---|
67 | " ); |
---|
68 | $stop = microtime( TRUE ); |
---|
69 | $time = number_format( $stop - $start, 2 ); |
---|
70 | echo " $time seconds\n"; |
---|
71 | |
---|
72 | echo "- Adding key on domain,path ... "; |
---|
73 | $start = microtime( TRUE ); |
---|
74 | $wpdb->query( " |
---|
75 | ALTER TABLE $test_table |
---|
76 | ADD INDEX domain_path (domain,path) |
---|
77 | " ); |
---|
78 | $stop = microtime( TRUE ); |
---|
79 | $time = number_format( $stop - $start, 2 ); |
---|
80 | echo " $time seconds\n"; |
---|
81 | |
---|
82 | echo "- Adding key on user_login,user_email ... "; |
---|
83 | $start = microtime( TRUE ); |
---|
84 | $wpdb->query( " |
---|
85 | ALTER TABLE $test_table |
---|
86 | ADD INDEX user_login_email (user_login,user_email) |
---|
87 | " ); |
---|
88 | $stop = microtime( TRUE ); |
---|
89 | $time = number_format( $stop - $start, 2 ); |
---|
90 | echo " $time seconds\n"; |
---|
91 | |
---|
92 | echo "- Adding key on user_email ... "; |
---|
93 | $start = microtime( TRUE ); |
---|
94 | $wpdb->query( " |
---|
95 | ALTER TABLE $test_table |
---|
96 | ADD INDEX user_email (user_email) |
---|
97 | " ); |
---|
98 | $stop = microtime( TRUE ); |
---|
99 | $time = number_format( $stop - $start, 2 ); |
---|
100 | echo " $time seconds\n"; |
---|
101 | |
---|
102 | echo "- Dropping $test_table ... "; |
---|
103 | $start = microtime( TRUE ); |
---|
104 | $wpdb->query( " |
---|
105 | DROP TABLE $test_table |
---|
106 | " ); |
---|
107 | $stop = microtime( TRUE ); |
---|
108 | $time = number_format( $stop - $start, 2 ); |
---|
109 | echo " $time seconds\n"; |
---|