--- title: Create an Index --- Search over massive collections of vectors can be slow. HNSW (Hierarchical Navigable Small World) is an algorithm that significantly accelerates vector search times. ## Basic Usage An HNSW index can be created over any column with the `vector` or `sparsevec` type. ```sql CREATE INDEX ON . USING hnsw ( ); ``` The name of the table being indexed. The name of the column being indexed. Must be of type `vector`. The distance metric used for measuring similarity between two vectors. For the `vector` data type, use `vector_l2_ops` for L2 distance, `vector_ip_ops` for inner product, and `vector_cosine_ops` for cosine distance. For the `sparsevec` data type, use `sparsevec_l2_ops` for L2 distance, `sparsevec_ip_ops` for inner product, and `sparsevec_cosine_ops` for cosine distance. The name of the schema, or namespace, of the table. If not provided, the search path is used as a default. ## Index Options The following example demonstrates how to pass options when creating the HNSW index: ```sql CREATE INDEX ON . USING hnsw ( ) WITH (m = 16, ef_construction = 64); ``` The maximum number of connections per layer. A higher value increases recall but also increases index size and construction time. A higher value creates a higher quality graph, which increases recall but also construction time.