SQL
x
/*
A backend replacement for https://tools.wmflabs.org/grep/
The current implementation of grep is very slow.
But as I've discovered by experimenting with this query,
"REGEXP" is not paricularly fast on its own either.
No, I was actually mistaken; regex works fine if it's set up correctly.
Earlier, I forgot SQL uses C-style strings,
and so I forgot to escape the "+" properly with 2 "\".
"LIKE" seemed much faster for some reason.
Starts with "C+": 1 sec vs. 67 sec
Starts with "N+": 0.36 sec vs. 47.94 sec
Starts with "U+": 5.44 sec vs. 37.66 sec
*/
/*
SET @regex_pattern = "^U\+";
SET @like_pattern = "U+%";
ns = 10
SET @regex_pattern = "^WP";
SET @like_pattern = "WP%";
-- 80.59 seconds
SET @regex_pattern = "TV_series\)$";
SET @like_pattern = "%TV_series)";
*/
SET @regex_pattern = "\(";
SET @like_pattern = "%(%";
USE enwiki_p; /* "Language" and "Project" */
SELECT page_title
FROM page
WHERE
page_namespace = 0 /* Namespace */
/* AND page_title REGEXP @regex_pattern /* "Pattern" */
AND page_title LIKE @like_pattern /* More straightforward option for pattern-based searching */
/* AND NOT page_is_redirect - negate "Include redirects" */
/* LIMIT 100 /* "Limit the display to the first 100 results" */
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.