Database / pgvector basics Interview Questions
How do you check and monitor pgvector index creation progress?
Building HNSW or IVFFlat indexes on large tables can take significant time (minutes to hours). PostgreSQL provides the pg_stat_progress_create_index view to monitor progress in real time.
-- Monitor index build progress: SELECT phase, round(100.0 * blocks_done / NULLIF(blocks_total, 0), 1) AS pct_complete, blocks_done, blocks_total, tuples_done, tuples_total FROM pg_stat_progress_create_index; -- Typical phases for HNSW index: -- 'initializing' -- 'loading tuples' -- 'done' -- Typical phases for IVFFlat index: -- 'initializing' -- 'performing k-means' -- 'assigning tuples' -- 'loading tuples' -- List existing indexes on a table: SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'documents'; -- Check index size: SELECT pg_size_pretty(pg_indexes_size('documents')); -- Speed up index builds with more memory and parallel workers: SET maintenance_work_mem = '4GB'; -- more memory = faster build SET max_parallel_maintenance_workers = 7; -- use multiple CPU cores -- Then create the index:
Performance tip: setting maintenance_work_mem higher is particularly important for HNSW index builds. The HNSW graph is constructed in memory, so more memory directly reduces build time. PostgreSQL's default of 64MB is far too low for large vector tables.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
