Skip to content

Instantly share code, notes, and snippets.

@kou
Created February 17, 2015 03:56
Show Gist options
  • Save kou/bc6406d921d01a9a89c1 to your computer and use it in GitHub Desktop.
Save kou/bc6406d921d01a9a89c1 to your computer and use it in GitHub Desktop.
FLUSH STATUS;
SET NAMES UTF8;
CREATE TABLE logs(
title TEXT,
content LONGTEXT,
a TINYINT,
b DATETIME,
c INT,
d DOUBLE,
FULLTEXT KEY (title, content) COMMENT 'parser "TokenMecab", normalizer "NormalizerAuto"',
KEY (a),
KEY (b),
KEY (c),
KEY (d)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Start Groonga", "X", 0, '2015-02-17 00:00:00', 1, 1.0);
INSERT INTO logs VALUES("Start Mroonga", "X", 0, '2015-02-17 00:00:01', 1, 2.0);
INSERT INTO logs VALUES("Start Groonga and Ruby", "X", 0, '2015-02-17 00:00:02', 1, 3.0);
SELECT * FROM logs;
SELECT *
FROM logs
WHERE MATCH (title, content) AGAINST ('+start' IN BOOLEAN MODE) AND
a = 0 AND
b < '2015-02-17 11:00:00' AND
c = 1
ORDER BY d DESC
LIMIT 0, 50;
-- title content a b c d
-- Start Groonga and Ruby X 0 2015-02-17 00:00:02 1 3
-- Start Mroonga X 0 2015-02-17 00:00:01 1 2
-- Start Groonga X 0 2015-02-17 00:00:00 1 1
SHOW STATUS LIKE 'mroonga_fast_order_limit';
-- Variable_name Value
-- Mroonga_fast_order_limit 1
DROP TABLE logs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment