{"id":19458518,"url":"https://github.com/postgrespro/wildspeed","last_synced_at":"2025-04-25T06:30:28.861Z","repository":{"id":139108890,"uuid":"100261185","full_name":"postgrespro/wildspeed","owner":"postgrespro","description":null,"archived":false,"fork":false,"pushed_at":"2017-08-14T12:08:22.000Z","size":16,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-24T10:48:44.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postgrespro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-14T11:39:49.000Z","updated_at":"2023-04-01T18:51:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"b81647f4-8be3-4e56-9935-5bac1e0a1e20","html_url":"https://github.com/postgrespro/wildspeed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fwildspeed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fwildspeed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fwildspeed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fwildspeed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postgrespro","download_url":"https://codeload.github.com/postgrespro/wildspeed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250766958,"owners_count":21483894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T17:27:24.936Z","updated_at":"2025-04-25T06:30:28.852Z","avatar_url":"https://github.com/postgrespro.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wildspeed - fast wildcard search for LIKE operator\n\nWildspeed extension provides GIN index support for wildcard search\nfor LIKE operator.\n\nOnline version of this document is available\nhttp://www.sai.msu.su/~megera/wiki/wildspeed\n\n## Authors\n\n* Oleg Bartunov \u003coleg@sai.msu.su\u003e, Moscow, Moscow University, Russia\n* Teodor Sigaev \u003cteodor@sigaev.ru\u003e, Moscow, Moscow University,Russia\n\n## License\n\nStable version, included into PostgreSQL distribution, released under\nBSD license. Development version, available from this site, released\nunder the GNU General Public License, version 2 (June 1991)\n\n## Downloads\n\nStable version of wildspeed is available from\nhttp://www.sigaev.ru/cvsweb/cvsweb.cgi/wildspeed/\n\n## Installation\n\n    % make USE_PGXS=1\n    % make install\n    % make installcheck\n    % psql DB -c 'CREATE EXTENSION wildspeed'\n\nWildspeed provides opclass (wildcard_ops) and uses partial match\nfeature of GIN, available since 8.4. Also, it supports full index scan.\n\nThe size of index can be very big, since it contains entries for all\npermutations of the original word, see [1] for details. For example,\nword hello will be indexed as well as its all permutations:\n\n    =# select permute('hello');\n                   permute\n    --------------------------------------\n     {hello$,ello$h,llo$he,lo$hel,o$hell}\n    \n       Notice, symbol '$' is used only for visualization, in actual\n       implementation null-symbol '\\0' is used.\n    \n       Search query rewritten as prefix search:\n    *X  -\u003e X$*\n    X*Y -\u003e Y$X*\n    *X* -\u003e X*\n\nFor example, search for 'hel*o' will be rewritten as 'o$hel'.\n\nSpecial function `permute(TEXT)`, which returns all permutations of\nargument, provided for test purposes.\n\nPerformance of wildspeed depends on search pattern. Basically,\nwildspeed is less effective than btree index with text_pattern_ops for\nprefix search (the difference is greatly reduced for long prefixes) and\nmuch faster for wildcard search.\n\nWildspeed by default uses optimization (skip short patterns if there\nare long one), which can be turned off in Makefile by removing define\n`-DOPTIMIZE_WILDCARD_QUERY`.\n\n## References\n\n* http://www.cs.wright.edu/~tkprasad/courses/cs499/L05TolerantIR.ppt\n* http://nlp.stanford.edu/IR-book/html/htmledition/permuterm-indexes-1.html\n\n## Examples\n\nTable words contains 747358 records, w1 and w2 columns contains the\nsame data in order to test performance of Btree (w1) and GIN (w2)\nindexes:\n\n       Table \"public.words\"\n     Column | Type | Modifiers\n    --------+------+-----------\n     w1     | text |\n     w2     | text |\n    \n    words=# create index bt_idx on words using btree (w1 text_pattern_ops);\n    CREATE INDEX\n    Time: 1885.195 ms\n    words=# create index gin_idx on words using gin (w2 wildcard_ops);\n    vacuum analyze;\n    CREATE INDEX\n    Time: 530351.223 ms\n\nSize:\n\n    words=# select pg_relation_size('words');\n     pg_relation_size\n    ------------------\n             43253760\n    \n    words=# select pg_relation_size('gin_idx');\n     pg_relation_size\n    ------------------\n            417816576\n    (1 row)\n    \n    words=# select pg_relation_size('bt_idx');\n     pg_relation_size\n    ------------------\n             23437312\n    (1 row)\n    \n       Prefix search:\n    words=# select count(*) from words where w1 like 'a%';\n     count\n    -------\n     15491\n    (1 row)\n    \n    Time: 7.502 ms\n    words=# select count(*) from words where w2 like 'a%';\n     count\n    -------\n     15491\n    (1 row)\n    \n    Time: 31.152 ms\n    \nWildcard search:\n\n    words=# select count(*) from words where w1 like '%asd%';\n     count\n    -------\n        26\n    (1 row)\n    \n    Time: 147.308 ms\n    words=# select count(*) from words where w2 like '%asd%';\n     count\n    -------\n        26\n    (1 row)\n    \n    Time: 0.339 ms\n    \nFull index scan:\n\n    words=# set enable_seqscan to off;\n    words=# explain analyze select count(*) from words where w2 like '%';\n                                                                    QUERY PLAN\n    \n    --------------------------------------------------------------------------------------------------------------\n    -----------------------------\n     Aggregate  (cost=226274.98..226274.99 rows=1 width=0) (actual time=2218.709..2218.709 rows=1 loops=1)\n       -\u003e  Bitmap Heap Scan on words  (cost=209785.73..224406.77 rows=747283 width=0) (actual time=1510.516..1913.\n    430 rows=747358 loops=1)\n             Filter: (w2 ~~ '%'::text)\n             -\u003e  Bitmap Index Scan on gin_idx  (cost=0.00..209598.91 rows=747283 width=0) (actual time=1509.358..1\n    509.358 rows=747358 loops=1)\n                   Index Cond: (w2 ~~ '%'::text)\n     Total runtime: 2218.747 ms\n    (6 rows)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fwildspeed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostgrespro%2Fwildspeed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fwildspeed/lists"}