USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll Bookspgvector Book
Homepgvector BookStart Here
PreviousRelational Databases and PostgreSQL from First PrinciplesNext Your First Vector Table and Similarity Query
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

11 sections

Progress0%
1 / 11

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Install PostgreSQL, pgvector, Python, and Docker

The safest beginner environment is a version-pinned PostgreSQL container image that already includes pgvector. It avoids modifying your operating-system database and makes cleanup reproducible. You will connect with psql, enable the extension inside one learning database, verify versions, and keep credentials in environment variables rather than source code.

What will you be able to do?

  • Start a disposable local PostgreSQL server with pgvector.
  • Connect through psql and inspect server details.
  • Enable and verify the vector extension.
  • Prepare Python and Git without storing secrets in code.
  • Choose between containers, packages, source builds, and managed services.

What do you need?

  • Docker Desktop or Docker Engine with Compose v2.
  • Git.
  • Python 3.11 or newer for the book's application labs.
  • About 2 GB of free disk space.

Lab: 20–35 minutes · Cost: free on your computer · Cleanup: remove the named container and volume shown below. Do not expose port 5432 to an untrusted network.

How do you start the learning database?

Use a pgvector image tag that exists for your platform and pin it in your learning repository. This example uses PostgreSQL 18; if your organization supports another current major version, change both the image and your compatibility tests.

yaml
services: db: image: pgvector/pgvector:pg18 environment: POSTGRES_DB: ai_native POSTGRES_USER: learner POSTGRES_PASSWORD: local-only-change-me ports: - "127.0.0.1:5432:5432" volumes: - pgvector_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U learner -d ai_native"] interval: 3s timeout: 3s retries: 20 volumes: pgvector_data:

For a shared repository, put the password in an uncommitted .env file and reference it from Compose. The literal above is acceptable only for an isolated local lab.

bash
docker compose up -d docker compose ps docker compose exec db psql -U learner -d ai_native

Inside psql:

sql
SELECT version(); CREATE EXTENSION IF NOT EXISTS vector; SELECT extname, extversion FROM pg_extension WHERE extname = 'vector'; SELECT current_database(), current_user;

Expected evidence is one vector row with an installed version and ai_native | learner. At the book verification date, upstream pgvector documentation references v0.8.6, but your pinned image determines the installed version.

How do you prepare Python?

bash
python3 --version python3 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip python -m pip install "psycopg[binary]>=3.2,<4" "pgvector>=0.4,<1"

Create an ignored local environment variable:

bash
export DATABASE_URL='postgresql://learner:local-only-change-me@127.0.0.1:5432/ai_native'

Never commit the URL. In production, obtain credentials from an approved secret manager and use TLS.

What are the installation alternatives?

  • Package manager: convenient when your operating system packages compatible PostgreSQL and pgvector builds.
  • Compile from source: offers control, but requires matching PostgreSQL development headers and careful upgrades.
  • Managed PostgreSQL: reduces server operations, but extension versions, privileges, regions, replicas, and upgrade timing differ by provider.
  • Kubernetes: useful only when your team already operates stateful workloads well; it is unnecessary for learning.

Follow upstream installation notes for Linux, macOS, or Windows rather than copying unverified build flags.

How do you verify it?

Run a disposable smoke test:

sql
CREATE TEMP TABLE smoke (embedding vector(3)); INSERT INTO smoke VALUES ('[1,2,3]'); SELECT embedding, vector_dims(embedding) AS dimensions FROM smoke;

Expected: [1,2,3] and 3. A temporary table disappears when the session ends.

What breaks in production?

  • The application and database use incompatible PostgreSQL or extension versions.
  • latest image tags change without review.
  • A development port binds to every network interface.
  • A volume is deleted under the assumption that a replica is a backup.
  • Extension creation requires privileges unavailable to the application role.

AI pair-work prompt

Given my OS [name/version] and CPU [architecture], produce a pgvector installation checklist using either Docker Compose or official upstream build instructions. Pin versions, explain where data persists, avoid public port binding, and include commands that print PostgreSQL and pgvector versions. Do not invent package names; link primary sources.

Verification contract: Accept the setup only after pg_isready, SELECT version(), the pg_extension query, and the temporary vector smoke test pass.

Check your understanding

  1. Why is CREATE EXTENSION vector executed per database?
  2. What persists after a container is removed but its named volume remains?
  3. Stop and restart the service; prove the database is still available.

Official references

  • pgvector installation
  • PostgreSQL client applications
  • Docker Compose documentation