I am trying to find the fastest way to insert data into a table (data from a select) I always clear the table:
TRUNCATE TABLE table;
Sonra veri eklemek için bunu:
INSERT INTO table(id,total) (SELECT id, COUNT(id) AS Total FROM table2 GROUP BY id);
Someone told me I shouldn't do this. He said this would be much faster:
CREATE TABLE IF NOT EXISTS table (PRIMARY KEY (inskey)) SELECT id, count(id) AS total FROM table2 GROUP BY id
Any ideas on this one? I think my solution is cleaner, because I don't have to check for the table. This will be ran in a cron job a few times a day
EDIT: Ben net değildi. Kesiği her zaman koştu. Bu neden tüm verileri eklemek için hızlı sadece meselesi