[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8055":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":15,"lastSyncTime":27,"discoverSource":28},8055,"dexter","ankane\u002Fdexter","ankane","The automatic indexer for Postgres","",null,"Ruby",2079,58,19,2,0,1,3,27.31,"MIT License",false,"master",[],"2026-06-12 02:01:48","# Dexter\n\nThe automatic indexer for Postgres\n\n[Read about how it works](https:\u002F\u002Fankane.org\u002Fintroducing-dexter) or [watch the talk](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=Mni_1yTaNbE)\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Factions)\n\n## Installation\n\nFirst, install [HypoPG](https:\u002F\u002Fgithub.com\u002FHypoPG\u002Fhypopg) on your database server. This doesn’t require a restart.\n\n```sh\ncd \u002Ftmp\ncurl -L https:\u002F\u002Fgithub.com\u002FHypoPG\u002Fhypopg\u002Farchive\u002F1.4.2.tar.gz | tar xz\ncd hypopg-1.4.2\nmake\nmake install # may need sudo\n```\n\nAnd enable it in databases where you want to use Dexter:\n\n```sql\nCREATE EXTENSION hypopg;\n```\n\nSee the [installation notes](#hypopg-installation-notes) if you run into issues.\n\nThen install the command line tool with:\n\n```sh\ngem install pgdexter\n```\n\nThe command line tool is also available with [Docker](#docker), [Homebrew](#homebrew), or as a [Linux package](guides\u002FLinux.md).\n\n## How to Use\n\nDexter needs a connection to your database and a source of queries (like [pg_stat_statements](https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fpgstatstatements.html)) to process.\n\n```sh\ndexter -d dbname --pg-stat-statements\n```\n\nThis finds slow queries and generates output like:\n\n```\nStarted\nProcessing 189 new query fingerprints\nIndex found: public.genres_movies (genre_id)\nIndex found: public.genres_movies (movie_id)\nIndex found: public.movies (title)\nIndex found: public.ratings (movie_id)\nIndex found: public.ratings (rating)\nIndex found: public.ratings (user_id)\n```\n\nTo be safe, Dexter will not create indexes unless you pass the `--create` flag. In this case, you’ll see:\n\n```\nIndex found: public.ratings (user_id)\nCreating index: CREATE INDEX CONCURRENTLY ON \"public\".\"ratings\" (\"user_id\")\nIndex created: 15243 ms\n```\n\n## Connection Options\n\nDexter supports the same connection options as psql.\n\n```\n-h host -U user -p 5432 -d dbname\n```\n\nThis includes URIs:\n\n```\npostgresql:\u002F\u002Fuser:pass@host:5432\u002Fdbname\n```\n\nand connection strings:\n\n```\nhost=localhost port=5432 dbname=mydb\n```\n\nAlways make sure your [connection is secure](https:\u002F\u002Fankane.org\u002Fpostgres-sslmode-explained) when connecting to a database over a network you don’t fully trust.\n\n## Collecting Queries\n\nDexter can collect queries from a number of sources.\n\n- [Query stats](#query-stats)\n- [Live queries](#live-queries)\n- [Log files](#log-files)\n- [SQL files](#sql-files)\n\n### Query Stats\n\nEnable [pg_stat_statements](https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fpgstatstatements.html) in your database.\n\n```psql\nCREATE EXTENSION pg_stat_statements;\n```\n\nAnd use:\n\n```sh\ndexter \u003Cconnection-options> --pg-stat-statements\n```\n\n### Live Queries\n\nGet live queries from the [pg_stat_activity](https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fmonitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW) view with:\n\n```sh\ndexter \u003Cconnection-options> --pg-stat-activity\n```\n\n### Log Files\n\nEnable logging for slow queries in your Postgres config file.\n\n```ini\nlog_min_duration_statement = 10 # ms\n```\n\nAnd use:\n\n```sh\ndexter \u003Cconnection-options> postgresql.log\n```\n\nSupports `stderr`, `csvlog`, and `jsonlog` formats.\n\nFor real-time indexing, pipe your logfile:\n\n```sh\ntail -F -n +1 postgresql.log | dexter \u003Cconnection-options> --stdin\n```\n\nAnd pass `--input-format csv` or `--input-format json` if needed.\n\n### SQL Files\n\nPass a SQL file with:\n\n```sh\ndexter \u003Cconnection-options> queries.sql\n```\n\nPass a single query with:\n\n```sh\ndexter \u003Cconnection-options> -s \"SELECT * FROM ...\"\n```\n\n## Collection Options\n\nTo prevent one-off queries from being indexed, specify a minimum number of calls before a query is considered for indexing\n\n```sh\ndexter --min-calls 100\n```\n\nYou can do the same for total time a query has run\n\n```sh\ndexter --min-time 10 # minutes\n```\n\nWhen streaming logs, specify the time to wait between processing queries\n\n```sh\ndexter --interval 60 # seconds\n```\n\n## Analyze\n\nFor best results, make sure your tables have been recently analyzed so statistics are up-to-date. You can ask Dexter to analyze tables it comes across that haven’t been analyzed in the past hour with:\n\n```sh\ndexter --analyze\n```\n\n## Tables\n\nYou can exclude large or write-heavy tables from indexing with:\n\n```sh\ndexter --exclude table1,table2\n```\n\nAlternatively, you can specify which tables to index with:\n\n```sh\ndexter --include table3,table4\n```\n\n## Debugging\n\nSee how Dexter is processing queries with:\n\n```sh\ndexter --log-sql --log-level debug2\n```\n\n## Hosted Postgres\n\nThe `hypopg` extension, which Dexter needs to run, is available on [these providers](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Fissues\u002F44).\n\nFor other providers, see [this guide](guides\u002FHosted-Postgres.md). To request a new extension:\n\n- Google Cloud SQL - vote or comment on [this page](https:\u002F\u002Fissuetracker.google.com\u002Fissues\u002F69250435)\n- DigitalOcean Managed Databases - vote or comment on [this page](https:\u002F\u002Fideas.digitalocean.com\u002Fmanaged-database\u002Fp\u002Fsupport-hypopg-for-postgres)\n\n## HypoPG Installation Notes\n\n### Postgres Location\n\nIf your machine has multiple Postgres installations, specify the path to [pg_config](https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fapp-pgconfig.html) with:\n\n```sh\nexport PG_CONFIG=\u002FApplications\u002FPostgres.app\u002FContents\u002FVersions\u002Flatest\u002Fbin\u002Fpg_config\n```\n\nThen re-run the installation instructions (run `make clean` before `make` if needed)\n\n### Missing Header\n\nIf compilation fails with `fatal error: postgres.h: No such file or directory`, make sure Postgres development files are installed on the server.\n\nFor Ubuntu and Debian, use:\n\n```sh\nsudo apt-get install postgresql-server-dev-17\n```\n\nNote: Replace `17` with your Postgres server version\n\n## Additional Installation Methods\n\n### Docker\n\nGet the [Docker image](https:\u002F\u002Fhub.docker.com\u002Fr\u002Fankane\u002Fdexter) with:\n\n```sh\ndocker pull ankane\u002Fdexter\n```\n\nAnd run it with:\n\n```sh\ndocker run -ti ankane\u002Fdexter \u003Cconnection-options>\n```\n\nFor databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires `--add-host=host.docker.internal:host-gateway`).\n\n### Homebrew\n\nWith Homebrew, you can use:\n\n```sh\nbrew install dexter\n```\n\n## Future Work\n\n[Here are some ideas](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Fissues\u002F45)\n\n## Upgrading\n\nRun:\n\n```sh\ngem install pgdexter\n```\n\nTo use master, run:\n\n```sh\ngem install specific_install\ngem specific_install https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter.git\n```\n\n## Thanks\n\nThis software wouldn’t be possible without [HypoPG](https:\u002F\u002Fgithub.com\u002FHypoPG\u002Fhypopg), which allows you to create hypothetical indexes, and [pg_query](https:\u002F\u002Fgithub.com\u002Flfittl\u002Fpg_query), which allows you to parse and fingerprint queries. A big thanks to Dalibo and Lukas Fittl respectively. Also, thanks to YugabyteDB for [this article](https:\u002F\u002Fdev.to\u002Fyugabyte\u002Fexplain-from-pgstatstatements-normalized-queries-how-to-always-get-the-generic-plan-in--5cfi) on how to explain normalized queries.\n\n## Research\n\nThis is known as the Index Selection Problem (ISP).\n\n## History\n\nView the [changelog](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Fblob\u002Fmaster\u002FCHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Fissues)\n- Fix bugs and [submit pull requests](https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter\u002Fpulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development, run:\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fankane\u002Fdexter.git\ncd dexter\nbundle install\nbundle exec rake install\n```\n\nTo run tests, use:\n\n```sh\ncreatedb dexter_test\nbundle exec rake test\n```\n","Dexter 是一个用于 PostgreSQL 的自动索引工具。它通过分析数据库中的查询来自动发现并推荐缺失的索引，从而提高查询性能。Dexter 支持从多种来源收集查询，包括 pg_stat_statements、实时活动查询以及日志文件等，并且提供了灵活的连接选项以适应不同的部署环境。用户可以通过命令行界面轻松安装和使用 Dexter，同时支持 Docker 和 Homebrew 等多种安装方式。适用于需要优化 PostgreSQL 数据库性能的各种场景，特别是那些频繁执行复杂查询的应用程序。","2026-06-11 03:15:50","top_language"]