Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. Exercise 7
  2.  
  3. 1.
  4.  
  5. Z:\FIRMA>mysql firma -u root -p < "luontiskripti2.sql"
  6. Enter password: ****
  7. ERROR 1506 (HY000) at line 27: Foreign key clause is not yet supported in conjun
  8. ction with partitioning
  9.  
  10. 2.
  11.  
  12. mysql> SELECT etunimi, sukunimi, palkka FROM tyontekija WHERE palkka > 3500;
  13.  
  14.  
  15. 3.
  16.  
  17. Without partitions.
  18.  
  19. Z:\public_html\Sql>mysqlslap --user=root --password --concurrency=5 --iterations
  20. =10 --create-schema=firma --query=slap.sql
  21. Enter password: ****
  22. Benchmark
  23. Average number of seconds to run all queries: 2.000 seconds
  24. Minimum number of seconds to run all queries: 1.953 seconds
  25. Maximum number of seconds to run all queries: 2.047 seconds
  26. Number of clients running queries: 5
  27. Average number of queries per client: 1
  28.  
  29. With partitioning.
  30.  
  31. Z:\public_html\Sql>mysqlslap --user=root --password --concurrency=5 --iterations
  32. =10 --create-schema=firma --query=slap.sql
  33. Enter password: ****
  34. Benchmark
  35. Average number of seconds to run all queries: 1.573 seconds
  36. Minimum number of seconds to run all queries: 0.765 seconds
  37. Maximum number of seconds to run all queries: 1.797 seconds
  38. Number of clients running queries: 5
  39. Average number of queries per client: 1
  40.  
  41. With indexing and partitioning.
  42.  
  43. Average was around 3.323 seconds, when we used FORCE command. It would not use indexing otherwise, because it was slower.
  44.  
  45. 4.
  46.  
  47. mysql> ALTER TABLE Tyontekija DROP PARTITION p0;
  48. Query OK, 0 rows affected (0.09 sec)
  49. Records: 0 Duplicates: 0 Warnings: 0
  50.  
  51. mysql> INSERT INTO Tyontekija VALUES (2555555, 'Vainikka', 'Joona', 2, 'Metropol
  52. ia', '00720', '0407534488', 1500)
  53. -> ;
  54. Query OK, 1 row affected (0.00 sec)
  55.  
  56. mysql> SELECT * FROM tyontekija WHERE sukunimi='Vainikka';
  57. +---------+----------+---------+--------+------------+---------+------------+---
  58. -----+
  59. | Numero | Sukunimi | Etunimi | Osasto | Lahios | Postino | Puhelin | Pa
  60. lkka |
  61. +---------+----------+---------+--------+------------+---------+------------+---
  62. -----+
  63. | 2555555 | Vainikka | Joona | 2 | Metropolia | 00720 | 0407534488 |
  64. 1500 |
  65. +---------+----------+---------+--------+------------+---------+------------+---
  66. -----+
  67. 1 row in set (0.17 sec)
  68.  
  69. mysql> EXPLAIN PARTITIONS SELECT * FROM tyontekija WHERE palkka=1500;
  70. +----+-------------+------------+------------+------+---------------+------+----
  71. -----+------+--------+-------------+
  72. | id | select_type | table | partitions | type | possible_keys | key | key
  73. _len | ref | rows | Extra |
  74. +----+-------------+------------+------------+------+---------------+------+----
  75. -----+------+--------+-------------+
  76. | 1 | SIMPLE | tyontekija | p1 | ALL | NULL | NULL | NUL
  77. L | NULL | 180820 | Using where |
  78. +----+-------------+------------+------------+------+---------------+------+----
  79. -----+------+--------+-------------+
  80. 1 row in set (0.00 sec)
  81.  
  82. As seen above I seem to go to partition1 with my 1500 euro salary.
  83. Because partition1 is for salaries less than 3000 euros.
  84.  
  85. 5.
  86.  
  87. Deleting a partition also deletes the information associated with that partition, allowing fast removal of information.
  88.  
  89. 6.
  90.  
  91. For example a log file, old logs are moved to partition0, and it is deleted at certain intervals while newer log files are kept in partition1.
  92.  
  93. 7.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement