diff --git a/src/box/key_def.cc b/src/box/key_def.cc
index 5099b87df5424c1d5cd708dc1f5c54f377ef7752..99a3d471b079b6a2887f60eefab0eaceee698648 100644
--- a/src/box/key_def.cc
+++ b/src/box/key_def.cc
@@ -104,6 +104,7 @@ const struct key_opts key_opts_default = {
 	/* .path                = */ { 0 },
 	/* .range_size          = */ 0,
 	/* .page_size           = */ 0,
+	/* .compact_wm          = */ 2,
 	/* .lsn                 = */ 0,
 };
 
@@ -114,6 +115,7 @@ const struct opt_def key_opts_reg[] = {
 	OPT_DEF("path", MP_STR, struct key_opts, path),
 	OPT_DEF("range_size", MP_UINT, struct key_opts, range_size),
 	OPT_DEF("page_size", MP_UINT, struct key_opts, page_size),
+	OPT_DEF("compact_wm", MP_UINT, struct key_opts, compact_wm),
 	OPT_DEF("lsn", MP_UINT, struct key_opts, lsn),
 	{ NULL, MP_NIL, 0, 0 }
 };
diff --git a/src/box/key_def.h b/src/box/key_def.h
index 0bf731db651b360d200a4a751c5f00d9177e951a..d49157ce5b39746a2d4fa99293725e33d2f20524 100644
--- a/src/box/key_def.h
+++ b/src/box/key_def.h
@@ -180,6 +180,11 @@ struct key_opts {
 	char path[PATH_MAX];
 	uint32_t range_size;
 	uint32_t page_size;
+	/**
+	 * Begin compaction when there are more than compact_wm
+	 * runs in a range.
+	 */
+	uint32_t compact_wm;
 	/**
 	 * LSN from the time of index creation.
 	 */
diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua
index b16bb5165476cba13907dc3a5f3be69ca58ef272..91cda43d79a547ac790c1e616ab1aa8f53c7d81d 100644
--- a/src/box/lua/schema.lua
+++ b/src/box/lua/schema.lua
@@ -386,6 +386,7 @@ box.schema.index.create = function(space_id, name, options)
         path = 'string',
         page_size = 'number',
         range_size = 'number',
+        compact_wm = 'number',
     }
     check_param_table(options, options_template)
     local options_defaults = {
@@ -407,6 +408,7 @@ box.schema.index.create = function(space_id, name, options)
             -- to a subdirectory of the server data dir if it is not set
             page_size = box.cfg.vinyl.page_size,
             range_size = box.cfg.vinyl.range_size,
+            compact_wm = box.cfg.vinyl.compact_wm,
         }
     else
         options_defaults = {}
@@ -452,6 +454,7 @@ box.schema.index.create = function(space_id, name, options)
             path = options.path,
             page_size = options.page_size,
             range_size = options.range_size,
+            compact_wm = options.compact_wm,
             lsn = box.info.cluster.signature,
     }
     local field_type_aliases = {
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 74419f7b63b6e880f0e6f2d6c5de3c6a03e5757b..23696820db378a0fe52d1ed1055a52f9ec61b3b0 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -91,11 +91,6 @@ struct vy_conf {
 	char *path;
 	/* memory */
 	uint64_t memory_limit;
-	/*
-	 * Begin compaction when there are more than compact_wm
-	 * runs in a range.
-	 */
-	uint32_t compact_wm;
 };
 
 struct vy_env {
@@ -3487,11 +3482,10 @@ vy_scheduler_peek_compact(struct vy_scheduler *scheduler,
 	struct vy_range *range;
 	struct heap_node *pn = NULL;
 	struct heap_iterator it;
-	uint32_t compact_wm = scheduler->env->conf->compact_wm;
 	vy_compact_heap_iterator_init(&scheduler->compact_heap, &it);
 	while ((pn = vy_compact_heap_iterator_next(&it))) {
 		range = container_of(pn, struct vy_range, nodecompact);
-		if (range->run_count < compact_wm)
+		if (range->run_count < range->index->key_def->opts.compact_wm)
 			break; /* TODO: why ? */
 		*ptask = vy_task_compact_new(&scheduler->task_pool,
 					     range);
@@ -3917,12 +3911,6 @@ vy_conf_new()
 	}
 	conf->memory_limit = cfg_getd("vinyl.memory_limit")*1024*1024*1024;
 
-	conf->compact_wm = cfg_geti("vinyl.compact_wm");
-	if (conf->compact_wm <= 1) {
-		vy_error("bad compact_wm value %d", conf->compact_wm);
-		goto error_1;
-	}
-
 	conf->path = strdup(cfg_gets("vinyl_dir"));
 	if (conf->path == NULL) {
 		diag_set(OutOfMemory, sizeof(*conf), "conf", "path");
diff --git a/test/vinyl/compact.result b/test/vinyl/compact.result
index 44289bd67e3bba42abb9b861bbb73cfdd87cc15c..8f59363139defe3ee9d2513302ba940f55beb871 100644
--- a/test/vinyl/compact.result
+++ b/test/vinyl/compact.result
@@ -7,7 +7,7 @@ fiber = require('fiber')
 space = box.schema.space.create("vinyl", { engine = 'vinyl' })
 ---
 ...
-_= space:create_index('primary', { parts = { 1, 'unsigned' } })
+_= space:create_index('primary', { parts = { 1, 'unsigned' }, compact_wm = 3 })
 ---
 ...
 function vyinfo() return box.info.vinyl().db[box.space.vinyl.id..'/0'] end
@@ -58,7 +58,7 @@ space:replace({2,2})
 space:upsert({2},{{'=',4,5}})
 ---
 ...
-box:snapshot() -- create the second run
+box.snapshot() -- create the second run
 ---
 - ok
 ...
@@ -66,6 +66,14 @@ vyinfo().run_count == 2
 ---
 - true
 ...
+space:insert({3, 3})
+---
+- [3, 3]
+...
+box.snapshot() -- create the third run to trigger compaction
+---
+- ok
+...
 -- wait for compaction
 while vyinfo().run_count >= 2 do fiber.sleep(0.1) end
 ---
diff --git a/test/vinyl/compact.test.lua b/test/vinyl/compact.test.lua
index 0a26d76f9565f609629f668b684f4b757e949977..5e44ab13b5c760164f0ad355ac54fa162ca3c363 100644
--- a/test/vinyl/compact.test.lua
+++ b/test/vinyl/compact.test.lua
@@ -2,7 +2,7 @@ test_run = require('test_run').new()
 fiber = require('fiber')
 
 space = box.schema.space.create("vinyl", { engine = 'vinyl' })
-_= space:create_index('primary', { parts = { 1, 'unsigned' } })
+_= space:create_index('primary', { parts = { 1, 'unsigned' }, compact_wm = 3 })
 
 function vyinfo() return box.info.vinyl().db[box.space.vinyl.id..'/0'] end
 
@@ -23,8 +23,10 @@ vyinfo().run_count == 1
 -- create the second run
 space:replace({2,2})
 space:upsert({2},{{'=',4,5}})
-box:snapshot() -- create the second run
+box.snapshot() -- create the second run
 vyinfo().run_count == 2
+space:insert({3, 3})
+box.snapshot() -- create the third run to trigger compaction
 
 -- wait for compaction
 while vyinfo().run_count >= 2 do fiber.sleep(0.1) end