G

ANALYZE

ANALYZE updates table statistics used by the adaptive query planner. The planner uses these statistics to decide between HNSW vector search and brute-force scan for SEMANTIC_MATCH queries.

Syntax

SQL
ANALYZE table_name;

Samples the table and updates statistics including:

  • Row count estimate (HyperLogLog NDV)
  • Column value distribution (equi-height histograms)
  • Multi-column correlation statistics
  • HNSW index size and recall estimate
SQL
ANALYZE docs;
-- ANALYZE docs: 8 rows sampled

Tip

Run ANALYZE after bulk inserts or significant data changes. The query planner uses stale statistics until ANALYZE is run, which may result in suboptimal query plans.

When to Run

Run ANALYZE in these situations:

  • After a large BULK INSERT (more than 10% of table size)
  • After creating a new table and inserting initial data
  • When SEMANTIC_MATCH queries seem slower than expected
  • As part of a scheduled maintenance window

The adaptive query planner uses statistics to decide between:

  • HNSW search — for large tables where approximate search is faster
  • Brute-force scan — for small tables (<1000 rows) where exact search is faster
SQL
-- After bulk insert, run ANALYZE
BULK INSERT INTO docs (id, body) VALUES
  (1, 'machine learning'),
  (2, 'deep learning'),
  -- ... 10,000 more rows
  (10000, 'natural language processing');

ANALYZE docs;

SHOW EMBEDDING HEALTH

Check the status of the embedding sidecar and the embedding queue:

SQL
-- Global sidecar status
SHOW EMBEDDING HEALTH;

-- Status for a specific table
SHOW EMBEDDING HEALTH FOR docs;

The response includes:

  • Sidecar process status (running/stopped)
  • Model loaded and ready
  • Embedding queue depth (pending embeddings)
  • Backlog depth (embeddings waiting to be processed)
bash
# Equivalent via HTTP
curl http://localhost:9090/health
# {"status":"ok","version":"1.0.0-beta.1","subsystems":{"disk_full":false,"sidecar_healthy":true,"connections_active":0}}

curl http://localhost:9090/metrics | grep embedding
# galaxdb_embedding_queue_depth 0
# galaxdb_embedding_backlog_depth 0
# galaxdb_sidecar_status 1