index_key_empty.slt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. simple conn=mz_system,user=mz_system
  10. ALTER SYSTEM SET unsafe_enable_table_keys TO true
  11. ----
  12. COMPLETE 0
  13. simple conn=mz_system,user=mz_system
  14. ALTER SYSTEM SET enable_mz_notices TO true
  15. ----
  16. COMPLETE 0
  17. # Disable rbac checks in order to select from mz_notices.
  18. simple conn=mz_system,user=mz_system
  19. ALTER SYSTEM SET enable_rbac_checks TO false
  20. ----
  21. COMPLETE 0
  22. statement ok
  23. CREATE SCHEMA notices;
  24. statement ok
  25. SET SCHEMA = notices;
  26. statement ok
  27. CREATE TABLE t (
  28. a int,
  29. b int
  30. );
  31. # Create an index that emits the optimizer notice.
  32. statement ok
  33. CREATE INDEX t_idx_empty_key ON t();
  34. # Verify that the notice is shown in EXPLAIN.
  35. query T multiline
  36. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions) AS VERBOSE TEXT FOR INDEX t_idx_empty_key;
  37. ----
  38. materialize.notices.t_idx_empty_key:
  39. ArrangeBy keys=[[]]
  40. ReadStorage materialize.notices.t
  41. Source materialize.notices.t
  42. Target cluster: quickstart
  43. Notices:
  44. - Notice: Empty index key. The index will be completely skewed to one worker thread, which can lead to performance problems.
  45. Hint: CREATE DEFAULT INDEX is almost always better than an index with an empty key. (Except for cross joins with big inputs, which are better to avoid anyway.)
  46. EOF
  47. # Verify that the same notice can be found in the catalog.
  48. query TTTTTTTT
  49. SELECT
  50. n.notice_type, n.message, n.redacted_message, n.hint, n.redacted_hint, n.action, n.redacted_action, n.action_type
  51. FROM
  52. mz_internal.mz_notices n JOIN
  53. mz_catalog.mz_indexes idx ON(n.object_id = idx.id)
  54. WHERE
  55. idx.name = 't_idx_empty_key'
  56. ----
  57. Empty index key
  58. Empty index key. The index will be completely skewed to one worker thread, which can lead to performance problems.
  59. NULL
  60. CREATE DEFAULT INDEX is almost always better than an index with an empty key. (Except for cross joins with big inputs, which are better to avoid anyway.)
  61. NULL
  62. Drop the enclosing index and re-create it using `CREATE DEFAULT INDEX ON` instead.
  63. NULL
  64. plain_text
  65. # Drop the catalog item associated with the notice.
  66. statement ok
  67. DROP INDEX t_idx_empty_key;
  68. # Verify that the notice is no longer in the catalog.
  69. query TTTTTTTT
  70. SELECT
  71. n.notice_type, n.message, n.redacted_message, n.hint, n.redacted_hint, n.action, n.redacted_action, n.action_type
  72. FROM
  73. mz_internal.mz_notices n JOIN
  74. mz_catalog.mz_indexes idx ON(n.object_id = idx.id)
  75. WHERE
  76. idx.name = 't_idx_empty_key'
  77. ----
  78. # This further tests `drop_plans_and_metainfos`
  79. statement ok
  80. DROP SCHEMA notices CASCADE;