Przejdź do treści
Biblioteka skilli
DevOps i chmura · Budowanie i kod

grepai-storage-postgres

/grepai-storage-postgres

Konfiguruje PostgreSQL z pgvector jako magazyn dla GrepAI w zespołowym środowisku i przy dużych bazach kodu.

Repozytorium
grepai-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
30.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 30.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Konfiguruje PostgreSQL z pgvector jako magazyn dla GrepAI w zespołowym środowisku i przy dużych bazach kodu.

Oryginalny opis (EN)

Configure PostgreSQL with pgvector for GrepAI. Use this skill for team environments and large codebases.

Jak działa

  1. When to Use This Skill
  2. Prerequisites
  3. Advantages
  4. Setting Up PostgreSQL with pgvector
  5. Configuration
  6. SSL Modes
  7. Database Schema
  8. Verifying Setup
  9. Performance Tuning
  10. Concurrent Access
Sekcje z nagłówków SKILL.md, w oryginale · 338 linii, 950 słów
Podgląd SKILL.md
---
name: grepai-storage-postgres
description: Configure PostgreSQL with pgvector for GrepAI. Use this skill for team environments and large codebases.
---

# GrepAI Storage with PostgreSQL

This skill covers using PostgreSQL with the pgvector extension as the storage backend for GrepAI.

## When to Use This Skill

- Team environments with shared index
- Large codebases (10K+ files)
- Need concurrent access
- Integration with existing PostgreSQL infrastructure

## Prerequisites

1. PostgreSQL 14+ with pgvector extension
2. Database user with create table permissions
3. Network access to PostgreSQL server

## Advantages

| Benefit | Description |
|---------|-------------|
| 👥 **Team sharing** | Multiple users can access same index |
| 📏 **Scalable** | Handles large codebases |
| 🔄 **Concurrent** | Multiple simultaneous searches |
| 💾 **Persistent** | Data survives machine restarts |
| 🔧 **Familiar** | Standard database tooling |

## Setting Up PostgreSQL with pgvector

### Option 1: Docker (Recommended for Development)

```bash
# Run PostgreSQL with pgvector
docker run -d \
  --name grepai-postgres \
  -e POSTGRES_USER=grepai \
  -e POSTGRES_PASSWORD=grepai \
  -e POSTGRES_DB=grepai \
  -p 5432:5432 \
  pgvector/pgvector:pg16
```

### Option 2: Install on Existing PostgreSQL

```bash
# Install pgvector extension (Ubuntu/Debian)
sudo apt install postgresql-16-pgvector

# Or compile from source
git clone https://github.com/pgvector/pgvector.git
cd pgvector
make
sudo make install
```

Then enable the extension:

```sql
-- Connect to your database
CREATE EXTENSION IF NOT EXISTS vector;
```

### Option 3: Managed Services

- **Supabase:** pgvector included by default
- **Neon:** pgvector available
- **AWS RDS:** Install pgvector extension
- **Azure Database:** pgvector available

## Configuration

### Basic Configuration

```yaml
# .grepai/config.yaml
store:
  backend: postgres
  postgres:
    dsn: postgres://user:password@localhost:5432/grepai
```

### Keeping the Password Out of the Config

grepai does not substitute `${VAR}` in `config.yaml`: `dsn: ${DATABASE_URL}` is used literally and fails. The DSN is passed to the pgx driver, which reads the standard libpq variables for anything the DSN leaves out, so you can drop the password from the config:

```yaml
store:
  backend: postgres
  postgres:
    dsn: postgres://user@localhost:5432/grepai
```

```bash
export PGPASSWORD="password"
```

### Full DSN Options

```yaml
store:
  backend: postgres
  postgres:
    dsn: postgres://user:password@host:5432/database?sslmode=require
```

DSN components:
- `user`: Database username
- `password`: Database password
- `host`: Server hostname or IP
- `5432`: Port (default: 5432)
- `database`: Database name
- `sslmode`: SSL mode (disable, require, verify-full)

## SSL Modes

| Mode | Description | Use Case |
|------|-------------|----------|
| `disable` | No SSL | Local development |
| `require` | SSL required | Production |
| `verify-full` | SSL + verify certificate | High security |

```yaml
# Production with SSL
store:
  backend: postgres
  postgres:
    dsn: postgres://user:pass@prod.db.com:5432/grepai?sslmode=require
```

## Database Schema

GrepAI automatically creates these tables:

```sql
-- Vector embeddings table
CREATE TABLE IF NOT EXISTS embeddings (
    id SERIAL PRIMARY KEY,
    file_path TEXT NOT NULL,
    chunk_index INTEGER NOT NULL,
    content TEXT NOT NULL,
    start_line INTEGER,
    end_line INTEGER,
    embedding vector(768),  -- Dimension matches your model
    created_at TIMESTAMP DEFAULT NOW(),
    UNIQUE(file_path, chunk_index)
);

-- Index for vector similarity search
CREATE INDEX ON embeddings USING ivfflat (embedding vector_cosine_ops);
```

## Verifying Setup

### Check pgvector Extension

```sql
-- Connect to database
psql -U grepai -d grepai

-- Check extension is installed
SELECT * FROM pg_extension WHERE extname = 'vector';

-- Check GrepAI tables exist (after first grepai watch)
\dt
```

### Test Connection from GrepAI

```bash
# Check status
grepai status

# Should show PostgreSQL backend info
```

## Performance Tuning

### PostgreSQL Configuration

For better vector search performance:

```sql
-- Increase work memory for vector operations
SET work_mem = '256MB';

-- Adjust for your hardware
SET effective_cache_size = '4GB';
SET shared_buffers = '1GB';
```

### Index Tuning

For large indices, tune the IVFFlat index:

```sql
-- More lists = faster search, more memory
CREATE INDEX ON embeddings
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);  -- Adjust based on row count
```

Rule of thumb: `lists = sqrt(rows)`

## Concurrent Access

PostgreSQL handles concurrent access automatically:

- Multiple `grepai search` commands work simultaneously
- One `grepai watch` daemon per codebase
- Many users can share the same index

## Team Setup

### Shared Database

All team members point to the same database:

```yaml
# Each developer's .grepai/config.yaml
store:
  backend: postgres
  postgres:
    dsn: postgres://team:secret@shared-db.company.com:5432/grepai
```

### Per-Project Databases

For isolated projects, use separate databases:

```bash
# Create databases
createdb -U postgres grepai_projecta
createdb -U postgres grepai_projectb
```

```yaml
# Project A config
store:
  backend: postgres
  postgres:
    dsn: postgres://user:pass@localhost:5432/grepai_projecta
```

## Backup and Restore

### Backup

```bash
pg_dump -U grepai -d grepai > grepai_backup.sql
```

### Restore

```bash
psql -U grepai -d grepai < grepai_backup.sql
```

## Migrating from GOB

1. Set up PostgreSQL with pgvector
2. Update configuration:
```yaml
store:
  backend: postgres
  postgres:
    dsn: postgres://user:pass@localhost:5432/grepai
```
3. Delete old index:
```bash
rm .grepai/index.gob
```
4. Re-index:
```bash
grepai watch
```

## Common Issues

❌ **Problem:** `FATAL: password authentication failed`
✅ **Solution:** Check DSN credentials and pg_hba.conf

❌ **Problem:** `ERROR: extension "vector" is not available`
✅ **Solution:** Install pgvector:
```bash
sudo apt install postgresql-16-pgvector
# Then: CREATE EXTENSION vector;
```

❌ **Problem:** `ERROR: type "vector" does not exist`
✅ **Solution:** Enable extension in the database:
```sql
CREATE EXTENSION IF NOT EXISTS vector;
```

❌ **Problem:** Connection refused
✅ **Solution:**
- Check PostgreSQL is running
- Verify host and port
- Check firewall rules

❌ **Problem:** Slow searches
✅ **Solution:**
- Add IVFFlat index
- Increase `work_mem`
- Vacuum and analyze tables

## Best Practices

1. **Use environment variables:** Don't commit credentials
2. **Enable SSL:** For remote databases
3. **Regular backups:** pg_dump before major changes
4. **Monitor performance:** Check query times
5. **Index maintenance:** Regular VACUUM ANALYZE

## Output Format

PostgreSQL storage status:

```
✅ PostgreSQL Storage Configured

   Backend: PostgreSQL + pgvector
   Host: localhost:5432
   Database: grepai
   SSL: disabled

   Contents:
   - Files: 2,450
   - Chunks: 12,340
   - Vector dimension: 768

   Performance:
   - Connection: OK
   - IVFFlat index: Yes
   - Search latency: ~50ms
```

Wersje

W bazie nie ma innych skilli o nazwie grepai-storage-postgres.

Migawka bazy z 13.11.2026 · wersja paczki 3f8d440fb2dc (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100grepai-storage-qdrant
    Konfiguruje bazę wektorową Qdrant jako magazyn dla GrepAI, gdy potrzebne jest szybkie wyszukiwanie wektorowe.
  • 100grepai-init
    Inicjalizuje GrepAI w projekcie przy pierwszej konfiguracji wyszukiwania w bazie kodu.
  • 100grepai-repo-setup
    Konfiguruje lub diagnozuje GrepAI dla jednego repozytorium Git we wspólnym workspace, w tym rejestrację projektu i indeks.
  • 100neon
    Wspiera pracę z serverless PostgreSQL w Neon: skalowanie do zera, natychmiastowy branching, pula połączeń i pgvector, na przykład dla baz w CI/CD i aplikacji edge.
  • 100postgres-patterns
    Stosuje wzorce PostgreSQL do optymalizacji zapytań, projektu schematu, indeksowania i bezpieczeństwa na bazie dobrych praktyk Supabase, także polityk RLS.
  • 90render-postgres
    Konfiguruje i optymalizuje zarządzany PostgreSQL na Render: limity połączeń, autoskalowanie dysku, wysoką dostępność i repliki.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.