You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
9.4 KiB

  1. SET SESSION STORAGE_ENGINE='InnoDB';
  2. set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch;
  3. set optimizer_switch='extended_keys=on';
  4. set @save_use_stat_tables=@@use_stat_tables;
  5. set use_stat_tables='preferably';
  6. DROP DATABASE IF EXISTS dbt3_s001;
  7. CREATE DATABASE dbt3_s001;
  8. use dbt3_s001;
  9. set @save_optimizer_switch=@@optimizer_switch;
  10. set optimizer_switch='extended_keys=off';
  11. select * from mysql.table_stats;
  12. db_name table_name cardinality
  13. dbt3_s001 customer 150
  14. dbt3_s001 lineitem 6005
  15. dbt3_s001 nation 25
  16. dbt3_s001 orders 1500
  17. dbt3_s001 part 200
  18. dbt3_s001 partsupp 700
  19. dbt3_s001 region 5
  20. dbt3_s001 supplier 10
  21. select * from mysql.index_stats;
  22. db_name table_name index_name prefix_arity avg_frequency
  23. dbt3_s001 customer PRIMARY 1 1.0000
  24. dbt3_s001 customer i_c_nationkey 1 6.0000
  25. dbt3_s001 lineitem PRIMARY 1 4.0033
  26. dbt3_s001 lineitem PRIMARY 2 1.0000
  27. dbt3_s001 lineitem i_l_shipdate 1 2.6500
  28. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  29. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  30. dbt3_s001 lineitem i_l_partkey 1 30.0250
  31. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  32. dbt3_s001 lineitem i_l_receiptdate 1 2.6477
  33. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  34. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  35. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  36. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  37. dbt3_s001 nation PRIMARY 1 1.0000
  38. dbt3_s001 nation i_n_regionkey 1 5.0000
  39. dbt3_s001 orders PRIMARY 1 1.0000
  40. dbt3_s001 orders i_o_orderdate 1 1.3321
  41. dbt3_s001 orders i_o_custkey 1 15.0000
  42. dbt3_s001 part PRIMARY 1 1.0000
  43. dbt3_s001 partsupp PRIMARY 1 3.5000
  44. dbt3_s001 partsupp PRIMARY 2 1.0000
  45. dbt3_s001 partsupp i_ps_partkey 1 3.5000
  46. dbt3_s001 partsupp i_ps_suppkey 1 70.0000
  47. dbt3_s001 region PRIMARY 1 1.0000
  48. dbt3_s001 supplier PRIMARY 1 1.0000
  49. dbt3_s001 supplier i_s_nationkey 1 1.1111
  50. flush table lineitem;
  51. set use_stat_tables='never';
  52. select sum(l_extendedprice*l_discount) as revenue
  53. from lineitem
  54. where l_shipdate >= date '1994-01-01'
  55. and l_shipdate < date '1994-01-01' + interval '1' year
  56. and l_discount between 0.06 - 0.01 and 0.06 + 0.01
  57. and l_quantity < 24;
  58. revenue
  59. 77949.91860000002
  60. set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
  61. set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
  62. use dbt3_s001;
  63. set use_stat_tables='preferably';
  64. select sum(l_extendedprice*l_discount) as revenue
  65. from lineitem
  66. where l_shipdate >= date '1994-01-01'
  67. and l_shipdate < date '1994-01-01' + interval '1' year
  68. and l_discount between 0.06 - 0.01 and 0.06 + 0.01
  69. and l_quantity < 24 ;
  70. set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
  71. set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
  72. use dbt3_s001;
  73. set use_stat_tables='preferably';
  74. select sum(l_extendedprice*l_discount) as revenue
  75. from lineitem
  76. where l_shipdate >= date '1994-01-01'
  77. and l_shipdate < date '1994-01-01' + interval '1' year
  78. and l_discount between 0.06 - 0.01 and 0.06 + 0.01
  79. and l_quantity < 24;
  80. revenue
  81. 77949.91860000002
  82. revenue
  83. 77949.91860000002
  84. set use_stat_tables='preferably';
  85. set debug_sync='RESET';
  86. select * from mysql.index_stats where table_name='lineitem' order by index_name;
  87. db_name table_name index_name prefix_arity avg_frequency
  88. dbt3_s001 lineitem PRIMARY 1 4.0033
  89. dbt3_s001 lineitem PRIMARY 2 1.0000
  90. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  91. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  92. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  93. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  94. dbt3_s001 lineitem i_l_partkey 1 30.0250
  95. dbt3_s001 lineitem i_l_receiptdate 1 2.6477
  96. dbt3_s001 lineitem i_l_shipdate 1 2.6500
  97. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  98. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  99. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  100. delete from mysql.index_stats
  101. where table_name='lineitem' and
  102. index_name in ('i_l_shipdate', 'i_l_receiptdate');
  103. select * from mysql.index_stats where table_name='lineitem' order by index_name;
  104. db_name table_name index_name prefix_arity avg_frequency
  105. dbt3_s001 lineitem PRIMARY 1 4.0033
  106. dbt3_s001 lineitem PRIMARY 2 1.0000
  107. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  108. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  109. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  110. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  111. dbt3_s001 lineitem i_l_partkey 1 30.0250
  112. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  113. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  114. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  115. analyze table lineitem persistent for columns() indexes (i_l_shipdate);
  116. select * from mysql.index_stats where table_name='lineitem' order by index_name;
  117. db_name table_name index_name prefix_arity avg_frequency
  118. dbt3_s001 lineitem PRIMARY 1 4.0033
  119. dbt3_s001 lineitem PRIMARY 2 1.0000
  120. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  121. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  122. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  123. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  124. dbt3_s001 lineitem i_l_partkey 1 30.0250
  125. dbt3_s001 lineitem i_l_shipdate 1 2.6500
  126. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  127. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  128. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  129. delete from mysql.index_stats
  130. where table_name='lineitem' and index_name= 'i_l_shipdate';
  131. select * from mysql.index_stats where table_name='lineitem' order by index_name;
  132. db_name table_name index_name prefix_arity avg_frequency
  133. dbt3_s001 lineitem PRIMARY 1 4.0033
  134. dbt3_s001 lineitem PRIMARY 2 1.0000
  135. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  136. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  137. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  138. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  139. dbt3_s001 lineitem i_l_partkey 1 30.0250
  140. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  141. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  142. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  143. set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
  144. set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
  145. use dbt3_s001;
  146. set use_stat_tables='preferably';
  147. analyze table lineitem persistent for columns() indexes (i_l_shipdate);
  148. set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
  149. set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
  150. use dbt3_s001;
  151. set use_stat_tables='preferably';
  152. analyze table lineitem persistent for columns() indexes (i_l_receiptdate);
  153. set debug_sync='RESET';
  154. select * from mysql.index_stats where table_name='lineitem' order by index_name;
  155. db_name table_name index_name prefix_arity avg_frequency
  156. dbt3_s001 lineitem PRIMARY 1 4.0033
  157. dbt3_s001 lineitem PRIMARY 2 1.0000
  158. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  159. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  160. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  161. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  162. dbt3_s001 lineitem i_l_partkey 1 30.0250
  163. dbt3_s001 lineitem i_l_receiptdate 1 2.6477
  164. dbt3_s001 lineitem i_l_shipdate 1 2.6500
  165. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  166. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  167. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  168. select * from mysql.index_stats where table_name='lineitem'
  169. order by index_name, prefix_arity;
  170. db_name table_name index_name prefix_arity avg_frequency
  171. dbt3_s001 lineitem PRIMARY 1 4.0033
  172. dbt3_s001 lineitem PRIMARY 2 1.0000
  173. dbt3_s001 lineitem i_l_commitdate 1 2.7160
  174. dbt3_s001 lineitem i_l_orderkey 1 4.0033
  175. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
  176. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  177. dbt3_s001 lineitem i_l_partkey 1 30.0250
  178. dbt3_s001 lineitem i_l_receiptdate 1 2.6477
  179. dbt3_s001 lineitem i_l_shipdate 1 2.6500
  180. dbt3_s001 lineitem i_l_suppkey 1 600.5000
  181. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
  182. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
  183. set debug_sync='RESET';
  184. set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
  185. use dbt3_s001;
  186. set use_stat_tables='preferably';
  187. analyze table lineitem persistent for all;
  188. set debug_sync='now WAIT_FOR parked';
  189. use dbt3_s001;
  190. set use_stat_tables='never';
  191. select * from lineitem where l_orderkey=1 and l_partkey=156;
  192. l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
  193. 1 156 4 1 17 17954.55 0.04 0.02 N O 1996-03-13 1996-02-12 1996-03-22 DELIVER IN PERSON TRUCK blithely regular ideas caj
  194. delete from lineitem where l_orderkey=1 and l_partkey=156;
  195. select * from lineitem where l_orderkey=1 and l_partkey=156;
  196. l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
  197. set debug_sync='now SIGNAL finish';
  198. set debug_sync='RESET';
  199. select * from mysql.index_stats where table_name='lineitem'
  200. order by index_name, prefix_arity;
  201. db_name table_name index_name prefix_arity avg_frequency
  202. dbt3_s001 lineitem PRIMARY 1 4.0027
  203. dbt3_s001 lineitem PRIMARY 2 1.0000
  204. dbt3_s001 lineitem i_l_commitdate 1 2.7155
  205. dbt3_s001 lineitem i_l_orderkey 1 4.0027
  206. dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0027
  207. dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
  208. dbt3_s001 lineitem i_l_partkey 1 30.0200
  209. dbt3_s001 lineitem i_l_receiptdate 1 2.6473
  210. dbt3_s001 lineitem i_l_shipdate 1 2.6496
  211. dbt3_s001 lineitem i_l_suppkey 1 600.4000
  212. dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0200
  213. dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5771
  214. DROP DATABASE dbt3_s001;
  215. use test;
  216. set use_stat_tables=@save_use_stat_tables;
  217. set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
  218. SET SESSION STORAGE_ENGINE=DEFAULT;