{"id":13469188,"url":"https://github.com/supabase/index_advisor","last_synced_at":"2025-04-08T10:29:49.571Z","repository":{"id":225854329,"uuid":"601328640","full_name":"supabase/index_advisor","owner":"supabase","description":"PostgreSQL Index Advisor","archived":false,"fork":false,"pushed_at":"2024-04-14T03:38:25.000Z","size":1150,"stargazers_count":1655,"open_issues_count":1,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-02T00:36:39.576Z","etag":null,"topics":["extension","indexing","postgres","postgresql"],"latest_commit_sha":null,"homepage":"https://supabase.com/docs/guides/database/extensions/index_advisor","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"postgresql","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/supabase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":["supabase"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2023-02-13T20:51:08.000Z","updated_at":"2025-03-31T21:54:37.000Z","dependencies_parsed_at":"2024-04-15T02:15:33.349Z","dependency_job_id":"5b87cc5b-276d-4c8d-98c7-29a866671dcd","html_url":"https://github.com/supabase/index_advisor","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.05714285714285716,"last_synced_commit":"ddb9b4ed17692ef8dbf049fad806426a851a3079"},"previous_names":["olirice/index_advisor","supabase/index_advisor"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supabase%2Findex_advisor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supabase%2Findex_advisor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supabase%2Findex_advisor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supabase%2Findex_advisor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/supabase","download_url":"https://codeload.github.com/supabase/index_advisor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608405,"owners_count":20966005,"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":["extension","indexing","postgres","postgresql"],"created_at":"2024-07-31T15:01:28.681Z","updated_at":"2025-04-08T10:29:49.553Z","avatar_url":"https://github.com/supabase.png","language":"PLpgSQL","funding_links":["https://github.com/sponsors/supabase"],"categories":["PLpgSQL"],"sub_categories":[],"readme":"# PostgreSQL Index Advisor\n\n\u003cp\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/postgresql-13+-blue.svg\" alt=\"PostgreSQL version\" height=\"18\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/supabase/index_advisor/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/supabase/index_advisor\" alt=\"License\" height=\"18\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/supabase/index_advisor/actions\"\u003e\u003cimg src=\"https://github.com/supabase/index_advisor/actions/workflows/test.yml/badge.svg\" alt=\"tests\" height=\"18\"\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\nA PostgreSQL extension for recommending indexes to improve query performance.\n\n![Dashboard](./docs/img/dashboard.png)\n\n## Features\n\n- Supports generic parameters e.g. `$1`, `$2`\n- Supports materialized views\n- Identifies tables/columns obfuscaed by views\n\n\n## API\n\n#### Description\nFor a given *query*, searches for a set of SQL DDL `create index` statements that improve the query's execution time;\n\n#### Signature\n```sql\nindex_advisor(query text)\nreturns\n    table  (\n        startup_cost_before jsonb,\n        startup_cost_after jsonb,\n        total_cost_before jsonb,\n        total_cost_after jsonb,\n        index_statements text[],\n        errors text[]\n    )\n```\n\n## Usage\n\nFor a minimal example, the `index_advisor` function can be given a single table query with a filter on an unindexed column.\n\n```sql\ncreate extension if not exists index_advisor cascade;\n\ncreate table book(\n  id int primary key,\n  title text not null\n);\n\nselect\n    *\nfrom\n  index_advisor('select book.id from book where title = $1');\n\n```\n\n```markdown\n startup_cost_before | startup_cost_after | total_cost_before | total_cost_after |                  index_statements                   | errors\n---------------------+--------------------+-------------------+------------------+-----------------------------------------------------+--------\n 0.00                | 1.17               | 25.88             | 6.40             | {\"CREATE INDEX ON public.book USING btree (title)\"},| {}\n\n(1 row)\n```\n\nMore complex queries may generate additional suggested indexes\n\n```sql\ncreate extension if not exists index_advisor cascade;\n\ncreate table author(\n    id serial primary key,\n    name text not null\n);\n\ncreate table publisher(\n    id serial primary key,\n    name text not null,\n    corporate_address text\n);\n\ncreate table book(\n    id serial primary key,\n    author_id int not null references author(id),\n    publisher_id int not null references publisher(id),\n    title text\n);\n\ncreate table review(\n    id serial primary key,\n    book_id int references book(id),\n    body text not null\n);\n\nselect\n    *\nfrom\n    index_advisor('\n        select\n            book.id,\n            book.title,\n            publisher.name as publisher_name,\n            author.name as author_name,\n            review.body review_body\n        from\n            book\n            join publisher\n                on book.publisher_id = publisher.id\n            join author\n                on book.author_id = author.id\n            join review\n                on book.id = review.book_id\n        where\n            author.id = $1\n            and publisher.id = $2\n    ');\n\n```\n\n```markdown\n startup_cost_before | startup_cost_after | total_cost_before | total_cost_after |                  index_statements                         | errors\n---------------------+--------------------+-------------------+------------------+-----------------------------------------------------------+--------\n 27.26               | 12.77              | 68.48             | 42.37            | {\"CREATE INDEX ON public.book USING btree (author_id)\",   | {}\n                                                                                    \"CREATE INDEX ON public.book USING btree (publisher_id)\",\n                                                                                    \"CREATE INDEX ON public.review USING btree (book_id)\"}\n(3 rows)\n```\n\n\n## Install\n\nRequires Postgres with [hypopg](https://github.com/HypoPG/hypopg) installed.\n\n```sh\ngit clone https://github.com/supabase/index_advisor.git\ncd index_advisor\nsudo make install\n```\n\n## Run Tests\n\n```sh\nmake install; make installcheck\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupabase%2Findex_advisor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupabase%2Findex_advisor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupabase%2Findex_advisor/lists"}