Skip to main content

Specialized PostgreSQL Variants

Appliku offers three specialized PostgreSQL builds that extend the standard engine with domain-specific capabilities. These are provisioned using the same workflow as regular PostgreSQL -- just select the specialized version from the dropdown.

Available Variants

VariantBase VersionUse Case
PostGIS 16 + 3.4PostgreSQL 16Geospatial data and location queries
pgvectorPostgreSQL 16AI/ML vector similarity search
TimescaleDBPostgreSQL 15Time-series data and analytics

Provisioning

The provisioning flow is identical to standard PostgreSQL:

  1. Open your application in the Appliku dashboard
  2. On the Application Overview page, scroll to the Databases block (bottom-right sidebar)
  3. Click Add Database
  4. Select the specialized variant from the dropdown (e.g., PostGIS 16+3.4)
  5. Select the server where the database should run
  6. Click Create

Connection URLs are automatically injected as environment variables, just like standard PostgreSQL.


PostGIS

PostGIS adds geospatial data types, spatial indexing, and geographic query functions to PostgreSQL. It is the industry standard for storing and querying location data.

Version: PostgreSQL 16 + PostGIS 3.4

When to Use PostGIS

  • Store and query geographic coordinates (points, polygons, lines)
  • Calculate distances between locations
  • Find nearby points of interest
  • Work with GeoJSON data
  • Build mapping or logistics applications

Django with PostGIS

Django's django.contrib.gis (GeoDjango) has native PostGIS support:

DATABASES = {
"default": {
"ENGINE": "django.contrib.gis.db.backends.postgis",
"NAME": "...",
# Or parse from DATABASE_URL using dj-database-url with
# the GIS engine override
}
}

Ensure GDAL and GEOS libraries are available in your build image or Dockerfile.


pgvector

pgvector adds vector data types and similarity search operators to PostgreSQL. It enables storing and querying high-dimensional embeddings directly in your database.

When to Use pgvector

  • Store embeddings from OpenAI, Cohere, or other AI models
  • Perform nearest-neighbor similarity search
  • Build semantic search, recommendation engines, or RAG pipelines
  • Avoid running a separate vector database (e.g., Pinecone, Weaviate)

Example Usage

-- Enable the extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Create a table with a vector column
CREATE TABLE documents (
id SERIAL PRIMARY KEY,
content TEXT,
embedding vector(1536) -- OpenAI ada-002 dimension
);

-- Insert a vector
INSERT INTO documents (content, embedding)
VALUES ('Hello world', '[0.1, 0.2, ...]');

-- Find nearest neighbors
SELECT id, content
FROM documents
ORDER BY embedding <-> '[0.1, 0.2, ...]'
LIMIT 5;

Python with pgvector

# pip install pgvector
from pgvector.psycopg2 import register_vector
import psycopg2

conn = psycopg2.connect(os.environ["DATABASE_URL"])
register_vector(conn)

TimescaleDB

TimescaleDB extends PostgreSQL with hypertables optimized for time-series data. It provides automatic partitioning, compression, and time-based query optimizations.

Version: Based on PostgreSQL 15

When to Use TimescaleDB

  • IoT sensor data and device telemetry
  • Application metrics and monitoring data
  • Financial time-series (stock prices, transactions)
  • Event logging with time-based queries
  • Any workload where data is primarily appended and queried by time range

Example Usage

-- Create a regular table
CREATE TABLE metrics (
time TIMESTAMPTZ NOT NULL,
device_id INTEGER,
temperature DOUBLE PRECISION,
humidity DOUBLE PRECISION
);

-- Convert to a hypertable
SELECT create_hypertable('metrics', 'time');

-- Insert data normally
INSERT INTO metrics (time, device_id, temperature, humidity)
VALUES (NOW(), 1, 22.5, 45.0);

-- Time-based queries are automatically optimized
SELECT time_bucket('1 hour', time) AS hour,
AVG(temperature) AS avg_temp
FROM metrics
WHERE time > NOW() - INTERVAL '24 hours'
GROUP BY hour
ORDER BY hour;

Next Steps