To add semantic search to a Python application backed by PostgreSQL, enable the vector extension, store embeddings in a dimension-matched vector(n) column, wire up the pgvector integration for your database driver or ORM, and establish exact search as a baseline. Add HNSW or IVFFlat only after measuring relevance and latency on representative queries—including the filters your application actually uses.
pgvector provides PostgreSQL vector storage and similarity operations; pgvector-python connects those capabilities to Python libraries and drivers. This checklist takes you from schema setup to a tested retrieval design.
How do I use pgvector with Python?
There are two pieces to set up: PostgreSQL’s extension and the Python-side integration. The correct adapter steps depend on whether the application uses an ORM or a driver such as Psycopg or asyncpg; type registration is not one universal step.
1. Confirm versions, access, and embedding dimensions
- Record the PostgreSQL major version and installed pgvector extension version. Confirm that your database provider allows the extension and offers a version with the features you plan to use; availability varies by service and deployment.
- Choose the integration used by the application. The pgvector-python project documents support for Django, SQLAlchemy, SQLModel, Psycopg 3 and 2, asyncpg, pg8000, and Peewee.
- Record the embedding model and the dimension of its output. The schema, stored embeddings, and query embeddings must use compatible dimensions.
2. Enable the extension and create a matching column
In the target database, run CREATE EXTENSION IF NOT EXISTS vector; if your role and deployment environment permit extension installation. Define the embedding column with the actual dimension produced by your model, for example embedding vector(n), replacing n with that dimension rather than copying an arbitrary value.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Keep ordinary row identifiers, the source text or document reference, and the metadata needed to display and filter results. Similarity search is not authorization: enforce access controls in your application and validate that retrieval respects them.
3. Install and configure the matching Python adapter
Install the Python package with pip install pgvector, then follow the setup instructions for your specific ORM or driver in the official integration documentation. For example, SQLAlchemy uses a VECTOR column type and distance methods for nearest-neighbor ordering. Psycopg and asyncpg have driver-specific type registration paths. Async applications should use the documented async setup for their driver, not assume that a synchronous registration callback will work.
Before loading real data, insert and read back a controlled vector using the selected adapter. Confirm that the round trip preserves the expected values and that query vectors are passed through parameter binding supported by that adapter.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
How do I add semantic search to PostgreSQL?
Start with a correct nearest-neighbor query using the distance metric that matches the application’s retrieval goal. Run it with a small LIMIT before adding an approximate index, and check that stored and query embeddings have the expected dimensions.
Choose a distance metric deliberately
pgvector supports L2 distance, inner product, cosine distance, and other operations. The query operator, the intended similarity measure, and any index operator class must agree. The Python project’s examples show metric-specific query methods and corresponding index operator classes; do not take an L2 index example and use it unchanged for cosine search.
Use exact search as the reference point
The pgvector README states: “By default, pgvector performs exact nearest neighbor search, which provides perfect recall.” Exact search gives you a useful reference for checking what an approximate index might miss. Build a representative evaluation set with queries and known relevant records, then record retrieval relevance and latency. Those results are application-specific; a documentation example is not a benchmark for your data.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Should I use HNSW or IVFFlat with pgvector?
Use exact search until measurements on your workload show a reason to trade recall or operational simplicity for approximate retrieval. If you need an approximate index, compare HNSW and IVFFlat using your data volume, filter patterns, concurrency, memory budget, and acceptable recall. The project’s comparison is qualitative rather than a promise of a fixed speedup.
| Consideration | HNSW | IVFFlat |
|---|---|---|
| Build behavior | Slower to build; can be created without a training step on preexisting rows. | Faster to build; create after the table has data. |
| Memory | Higher memory use. | Lower memory use. |
| Query speed/recall tradeoff | The pgvector project describes better query performance in this tradeoff. | The project describes lower query performance in this tradeoff. |
| Parameters to evaluate | Search and build parameters, plus iterative scans where applicable. | List count and probes, plus iterative scans where applicable. |
| Validation | Measure latency and recall on real queries and filters. | Measure latency and recall on real queries and filters. |
These are the project’s stated tradeoffs, not universal benchmark results. Actual behavior depends on data, extension version, parameters, hardware, and query shape. The README gives starting heuristics for IVFFlat list counts, but those still need workload validation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Match the index to the query
When creating an index, select the operator class for the distance operation used by your query. The Python integration examples include HNSW and IVFFlat configurations for SQLAlchemy and driver-level usage. After creation, compare indexed results against the exact baseline, not only against a latency target.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
How should I validate filtered and multi-tenant retrieval?
Test realistic queries with category, status, tenant, and other application filters. An unfiltered nearest-neighbor test can conceal a problem that appears once production filters are applied.
The pgvector project warns that filtering for approximate-index queries happens after the index scan, so a query can return fewer matches than its LIMIT requests. Starting with pgvector 0.8.0, iterative index scans can continue scanning until enough matches are found or configured limits are reached. Check the installed extension version before relying on iterative scans.
- For a small number of distinct filter values, consider a partial index.
- For many filter values, consider partitioning.
- For multi-tenant workloads, validate both isolation and retrieval quality. The project notes that vectors belonging to one tenant in a shared approximate index can affect another tenant’s speed and recall; list partitioning or separate tables are documented isolation options.
These approaches are described in the pgvector project README. Choose among them based on measured filter distributions and your application’s isolation requirements.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
How do I combine vector search with PostgreSQL full-text search?
Semantic similarity may miss exact identifiers, rare terms, or words that need to match literally. When those matches matter, run PostgreSQL full-text search alongside vector retrieval and evaluate the combined results. PostgreSQL’s full-text search documentation covers its text-search facilities, and the pgvector README describes combining lexical and vector retrieval.
The official pgvector-python hybrid-search example ranks semantic and keyword results separately, then combines those ranks with Reciprocal Rank Fusion (RRF). The project also points to a cross-encoder example as another option. Treat RRF and reranking as approaches to test, not guaranteed relevance improvements: compare relevance and runtime on representative queries.
How should I load data and operate the index?
Bulk-load before building indexes
For bulk ingestion, pgvector recommends PostgreSQL’s COPY command and says to add indexes after the initial data load for best performance. This is especially relevant when creating an IVFFlat index, which should be built after the table contains data.
Plan production index creation
For production, the pgvector README recommends creating indexes concurrently to avoid blocking writes. Follow the restrictions and deployment process for the PostgreSQL version you run; the PostgreSQL 18 CREATE INDEX documentation describes version-specific index creation behavior.
Diagnose plans and quality together
Use EXPLAIN (ANALYZE, BUFFERS) to inspect query plans and runtime behavior. Test on production-like data and record recall or relevance alongside latency: execution time alone cannot show whether approximate retrieval returns acceptable results.
If memory or index footprint becomes a constraint, pgvector documents options including half-precision vectors and indexing, as well as binary quantization with reranking. These are optimization paths to validate for quality and runtime, not default first steps.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

