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
*/
SET @regex_pattern = "^C\\+";
SET @like_pattern = "N+%";
USE enwiki_p; /* "Language" and "Project" */
SELECT *
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.