Skip to content

Instantly share code, notes, and snippets.

@dbolser-ebi
Created February 10, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbolser-ebi/6613cbc375c773f95543 to your computer and use it in GitHub Desktop.
Save dbolser-ebi/6613cbc375c773f95543 to your computer and use it in GitHub Desktop.
DROP TABLE IF EXISTS temp_individual_genotype_a;
Query OK, 0 rows affected (0.02 sec)
CREATE TABLE temp_individual_genotype_a
-> (INDEX pk_ish (variation_id, population_id, allele_code_id))
-> SELECT
-> variation_id, population_id, allele_code_id_1 AS allele_code_id,
-> `COUNT(*)` AS N
-> FROM temp_individual_genotype_a1 LIMIT 6000000;
Query OK, 6000000 rows affected, 1 warning (6.08 sec)
Records: 6000000 Duplicates: 0 Warnings: 1
INSERT INTO temp_individual_genotype_a
-> SELECT
-> variation_id, population_id, allele_code_id_2 AS allele_code_id,
-> `COUNT(*)` AS N
-> FROM temp_individual_genotype_a2 LIMIT 6000000;
Query OK, 6000000 rows affected, 1 warning (20.63 sec)
Records: 6000000 Duplicates: 0 Warnings: 1
OPTIMIZE TABLE temp_individual_genotype_a;
+---------------------------------------------------------------------+----------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+---------------------------------------------------------------------+----------+----------+----------+
| solanum_lycopersicum_variation_26_79_240.temp_individual_genotype_a | optimize | status | OK |
+---------------------------------------------------------------------+----------+----------+----------+
1 row in set (2.96 sec)
EXPLAIN
-> SELECT *, COUNT(*), SUM(N) FROM temp_individual_genotype_a GROUP BY variation_id, population_id, allele_code_id;
+----+-------------+----------------------------+------+---------------+------+---------+------+----------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------------------+------+---------------+------+---------+------+----------+---------------------------------+
| 1 | SIMPLE | temp_individual_genotype_a | ALL | NULL | NULL | NULL | NULL | 12000000 | Using temporary; Using filesort |
+----+-------------+----------------------------+------+---------------+------+---------+------+----------+---------------------------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment