{"id":23959566,"url":"https://github.com/otobrglez/speedy-limeta","last_synced_at":"2026-05-30T16:31:08.116Z","repository":{"id":138274269,"uuid":"111946188","full_name":"otobrglez/speedy-limeta","owner":"otobrglez","description":"Experimenting with GIN index (intarray) in PostgreSQL","archived":false,"fork":false,"pushed_at":"2017-11-24T18:28:39.000Z","size":3384,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T12:17:20.965Z","etag":null,"topics":["postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/otobrglez.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-11-24T18:28:16.000Z","updated_at":"2017-11-24T18:31:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e861461-d453-47a6-885f-8a14aa34f556","html_url":"https://github.com/otobrglez/speedy-limeta","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/otobrglez/speedy-limeta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otobrglez%2Fspeedy-limeta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otobrglez%2Fspeedy-limeta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otobrglez%2Fspeedy-limeta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otobrglez%2Fspeedy-limeta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otobrglez","download_url":"https://codeload.github.com/otobrglez/speedy-limeta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otobrglez%2Fspeedy-limeta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33700863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["postgresql","sql"],"created_at":"2025-01-06T18:49:25.926Z","updated_at":"2026-05-30T16:31:08.103Z","avatar_url":"https://github.com/otobrglez.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Speedy Limeta\n\n## Question\n\n\u003e Nekoč sem se srečal s situacijo, ko je v SQL bazi seznam vseh veljavnih besed (cca 100k).\nImaš npr 8 črk, zanima pa te katere vse besede iz slovarja lahko sestaviš s temi 8 ali manj črkami.\nPrimer: vhod ETRAMOIL, rešitve MILA, TAM, IME, LIMETA,... // [Uroš Kotolenko](https://twitter.com/ukotolenko) at [Slovenski Developerji](https://www.facebook.com/groups/272812582821861/permalink/1097738063662638/), November 2017  \n\n## Setup\n\nPrepare PostgreSQL...\n\n```bash\n# Create PG file structure\ninitdb -E utf8 db/pg-data -U postgres \n\n# Run PG in foreground\npostgres -D db/pg-data\n\n# Create database\ncreatedb limeta -E utf8 -U postgres\n\n# Create tables and load words\npsql -U postgres limeta -a -f ./create_tables.sql\n\n# Load words\npsql -U postgres limeta -a -c \"COPY words FROM '$(PWD)/data/words_si-SL.csv' CSV DELIMITER ','\"\n```\n\n## Database structure\n\n```sql\nDROP TABLE IF EXISTS words;\nCREATE EXTENSION IF NOT EXISTS intarray;\n\nCREATE TABLE words (\n  word          VARCHAR(60) NOT NULL,\n  letter_numbers INT []\n);\n\nCREATE INDEX idx_letter_number ON words USING GIN(letter_numbers gin__int_ops);\n```\n\n## Lookup\n\n```sql\nWITH wan AS (\n\tSELECT ARRAY(SELECT ascii(unnest(regexp_split_to_array(upper('ETRAMOIL'), ''))))::int[] as lookup_numbers\n)\nSELECT words.word\nFROM wan, words\nWHERE wan.lookup_numbers @\u003e words.letter_numbers\nORDER BY icount(wan.lookup_numbers \u0026 words.letter_numbers) DESC\n```\n\n## Explain\n\n```bash\npsql -U postgres limeta -qAt -f lookup.sql \u003e analyse.json\n```\n\n![Explain](plan.png \"Explain visualized\")\n\n\n## Data preparation / cleanup\n\n```bash\n./cleanup_words.py \u003e ./data/words-si-SL.csv\n```\n\n## Credits\n\n- [Slovar besed slovenskega jezika - Inštitut za slovenski jezik Frana Ramovša ZRC SAZU](http://bos.zrc-sazu.si/sbsj.html), November 2017\n\n## Author\n\n- [Oto Brglez](https://github.com/otobrglez)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotobrglez%2Fspeedy-limeta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotobrglez%2Fspeedy-limeta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotobrglez%2Fspeedy-limeta/lists"}