https://github.com/amhsirak/pg-index
Indexing on a Postgres table containing 50 million rows
https://github.com/amhsirak/pg-index
database db-index indexing postgresql sql
Last synced: 6 months ago
JSON representation
Indexing on a Postgres table containing 50 million rows
- Host: GitHub
- URL: https://github.com/amhsirak/pg-index
- Owner: amhsirak
- Created: 2023-08-07T10:23:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-07T14:32:54.000Z (over 2 years ago)
- Last Synced: 2025-01-26T04:27:30.009Z (about 1 year ago)
- Topics: database, db-index, indexing, postgresql, sql
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### What is this?
Simple experiment to apply database indexing to improve query performance for a hypothetical `customer` table containing 50 million rows. Partial Index is created on `country` column, containing two distinct values - 'India' & 'United Kingdom'
### Test Environment
- PostgreSQL 13
- PgAdmin 4
- Windows 11 HSL (AMD Ryzen 5)
### Results
For the query `SELECT * FROM customers WHERE country='United Kingdom';`
Using `EXPLAIN ANALYZE` query for obtaining actual run-time statistics on the required statement before and after indexing.
- Query Execution Time without index: 41836.270 ms
- Query Execution Time with index: 24254.644 ms
- Improvement in query execution time ~42.03%
Related article can be found here.