merge.asciidoc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. [[index-modules-merge]]
  2. == Merge
  3. experimental[All of the settings exposed in the `merge` module are expert only and may be removed in the future]
  4. A shard in elasticsearch is a Lucene index, and a Lucene index is broken
  5. down into segments. Segments are internal storage elements in the index
  6. where the index data is stored, and are immutable up to delete markers.
  7. Segments are, periodically, merged into larger segments to keep the
  8. index size at bay and expunge deletes.
  9. Merges segments of approximately equal size, subject to an allowed
  10. number of segments per tier. The merge policy is able to merge
  11. non-adjacent segments, and separates how many segments are merged at once from how many
  12. segments are allowed per tier. It also does not over-merge (i.e., cascade merges).
  13. The merge policy has the following settings:
  14. `index.merge.policy.expunge_deletes_allowed`::
  15. When expungeDeletes is called, we only merge away a segment if its delete
  16. percentage is over this threshold. Default is `10`.
  17. `index.merge.policy.floor_segment`::
  18. Segments smaller than this are "rounded up" to this size, i.e. treated as
  19. equal (floor) size for merge selection. This is to prevent frequent
  20. flushing of tiny segments, thus preventing a long tail in the index. Default
  21. is `2mb`.
  22. `index.merge.policy.max_merge_at_once`::
  23. Maximum number of segments to be merged at a time during "normal" merging.
  24. Default is `10`.
  25. `index.merge.policy.max_merge_at_once_explicit`::
  26. Maximum number of segments to be merged at a time, during optimize or
  27. expungeDeletes. Default is `30`.
  28. `index.merge.policy.max_merged_segment`::
  29. Maximum sized segment to produce during normal merging (not explicit
  30. optimize). This setting is approximate: the estimate of the merged segment
  31. size is made by summing sizes of to-be-merged segments (compensating for
  32. percent deleted docs). Default is `5gb`.
  33. `index.merge.policy.segments_per_tier`::
  34. Sets the allowed number of segments per tier. Smaller values mean more
  35. merging but fewer segments. Default is `10`. Note, this value needs to be
  36. >= than the `max_merge_at_once` otherwise you'll force too many merges to
  37. occur.
  38. `index.merge.policy.reclaim_deletes_weight`::
  39. Controls how aggressively merges that reclaim more deletions are favored.
  40. Higher values favor selecting merges that reclaim deletions. A value of
  41. `0.0` means deletions don't impact merge selection. Defaults to `2.0`.
  42. For normal merging, the policy first computes a "budget" of how many
  43. segments are allowed to be in the index. If the index is over-budget,
  44. then the policy sorts segments by decreasing size (proportionally considering percent
  45. deletes), and then finds the least-cost merge. Merge cost is measured by
  46. a combination of the "skew" of the merge (size of largest seg divided by
  47. smallest seg), total merge size and pct deletes reclaimed, so that
  48. merges with lower skew, smaller size and those reclaiming more deletes,
  49. are favored.
  50. If a merge will produce a segment that's larger than
  51. `max_merged_segment` then the policy will merge fewer segments (down to
  52. 1 at once, if that one has deletions) to keep the segment size under
  53. budget.
  54. Note, this can mean that for large shards that holds many gigabytes of
  55. data, the default of `max_merged_segment` (`5gb`) can cause for many
  56. segments to be in an index, and causing searches to be slower. Use the
  57. indices segments API to see the segments that an index has, and
  58. possibly either increase the `max_merged_segment` or issue an optimize
  59. call for the index (try and aim to issue it on a low traffic time).
  60. |=======================================================================
  61. [float]
  62. [[scheduling]]
  63. === Scheduling
  64. The merge scheduler (ConcurrentMergeScheduler) controls the execution of
  65. merge operations once they are needed (according to the merge policy). Merges
  66. run in separate threads, and when the maximum number of threads is reached,
  67. further merges will wait until a merge thread becomes available. The merge
  68. scheduler supports this setting:
  69. `index.merge.scheduler.max_thread_count`::
  70. The maximum number of threads that may be merging at once. Defaults to
  71. `Math.max(1, Math.min(4, Runtime.getRuntime().availableProcessors() / 2))`
  72. which works well for a good solid-state-disk (SSD). If your index is on
  73. spinning platter drives instead, decrease this to 1.
  74. `index.merge.scheduler.auto_throttle`::
  75. If this is true (the default), then the merge scheduler will
  76. rate-limit IO (writes) for merges to an adaptive value depending on
  77. how many merges are requested over time. An application with a low
  78. indexing rate that unluckily suddenly requires a large merge will see
  79. that merge aggressively throttled, while an application doing heavy
  80. indexing will see the throttle move higher to allow merges to keep up
  81. with ongoing indexing. This is a dynamic setting (you can <<indices-update-settings,change it
  82. at any time on a running index>>).