DROP TABLE IF EXISTS memos;
DROP TABLE IF EXISTS users;
SET NAMES utf8mb4;
CREATE TABLE users (
user_id INT UNSIGNED,
sort_order INT
) ENGINE=InnoDB;
CREATE TABLE memos (
id INT UNSIGNED,
user_id INT UNSIGNED,
content TEXT,
FULLTEXT INDEX(content)
) DEFAULT CHARSET utf8mb4;
INSERT INTO users VALUES(1, 0);
INSERT INTO users VALUES(2, 1);
INSERT INTO users VALUES(3, -1);
INSERT INTO memos VALUES(1, 3, 'Groonga is fast.');
INSERT INTO memos VALUES(2, 1, 'Mroonga is based on Groonga.');
INSERT INTO memos VALUES(3, 2, 'Groonga is embeddable full text search engine.');
SELECT *
FROM users
WHERE user_id IN (
SELECT user_id
FROM memos
WHERE MATCH(content) AGAINST('*D+ Groonga -embeddable' IN BOOLEAN MODE)
)
ORDER BY sort_order
LIMIT 1;
user_id	sort_order
3	-1
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name	Value
Mroonga_fast_order_limit	0
DROP TABLE memos;
DROP TABLE users;
