I am a new comer to mysql. I have to unify these 2 place to create my speed up, but I'm not sure well sql programming.
First I must populate wordpress_terms, compared to wordpress_term_taxonomy while using term_id as key.
That one produce a row with term_id (area term_id not present, is really a AUTOINCREMENT one) = 1
INSERT INTO wp_terms(name, slug, term_group) VALUES ('Pippo','pippo'0)
So, to create relationship between two tables I made use of that one:
INSERT INTO wp_term_taxonomy (term_id,taxonomy,parent) SELECT wp_terms.term_id,'category','1' FROM wp_terms WHERE NOT EXISTS (SELECT * FROM wp_term_taxonomy WHERE wp_terms.term_id = wp_term_taxonomy.term_id);
How do i run above place simultaneously?
One method to allow it to be faster is by using transaction. They're a lot more faster.
From MySQL manual this is a quote,
To acquire faster insertions for transactional tables, you need to use START TRANSACTION and COMMIT rather than LOCK TABLES.
To accelerate Place procedures which are carried out with multiple claims for nontransactional tables, lock your tables:
This is actually the sql you will need. Modify it by any means. You may make loop at any kind.
START TRANSACTION; INSERT INTO wp_terms(name, slug, term_group) VALUES ('Pippo','pippo'0) SET @wp_terms_id = LAST_INSERT_ID() INSERT INTO wp_term_taxonomy (@wp_terms_id,taxonomy,parent); SET @wp_taxonomy_id = LAST_INSERT_ID(); SELECT wp_terms.term_id,'category','1' FROM wp_terms WHERE NOT EXISTS (SELECT * FROM wp_term_taxonomy WHERE wp_terms.term_id = wp_term_taxonomy.term_id); COMMIT;
Whenever you send
COMMIT all of the queries is going to be performed over night.
You should use "trigger after place". Here there's a tutorial http://www.roseindia.net/sql/trigger/mysql-trigger-after-insert.shtml