<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Vector search index very slow in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142474#M4495</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have created a vector search index for a delta table with 1,400 rows. Using this vector index to find matching records on a table with 52M records with the query below ran for 20hrs and failed with:&amp;nbsp;&lt;SPAN&gt;'HTTP request failed with status: {"error_code":403,"message":"Invalid access token.&amp;nbsp; Do you have any suggestions to improve performance?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Query:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;columns...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;delta table&lt;/EM&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; LATERAL (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VECTOR_SEARCH(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index =&amp;gt; "&lt;EM&gt;my vector index&lt;/EM&gt;",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_text =&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;column from delta table&lt;/EM&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_type =&amp;gt; 'ANN',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_results =&amp;gt; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;</description>
    <pubDate>Tue, 23 Dec 2025 18:42:14 GMT</pubDate>
    <dc:creator>RodrigoE</dc:creator>
    <dc:date>2025-12-23T18:42:14Z</dc:date>
    <item>
      <title>Vector search index very slow</title>
      <link>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142474#M4495</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have created a vector search index for a delta table with 1,400 rows. Using this vector index to find matching records on a table with 52M records with the query below ran for 20hrs and failed with:&amp;nbsp;&lt;SPAN&gt;'HTTP request failed with status: {"error_code":403,"message":"Invalid access token.&amp;nbsp; Do you have any suggestions to improve performance?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Query:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;columns...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;delta table&lt;/EM&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; LATERAL (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VECTOR_SEARCH(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index =&amp;gt; "&lt;EM&gt;my vector index&lt;/EM&gt;",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_text =&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;column from delta table&lt;/EM&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_type =&amp;gt; 'ANN',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_results =&amp;gt; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2025 18:42:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142474#M4495</guid>
      <dc:creator>RodrigoE</dc:creator>
      <dc:date>2025-12-23T18:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Vector search index very slow</title>
      <link>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142522#M4497</link>
      <description>&lt;P&gt;By using the lateral and joining to your table you are exploding out the data to a point it will struggle to handle it. I would consider breaking your table and vector search index in into managable chunks and processing in stages. Usually you know you don't need to join everything to everything to search. You may also want to consider not doing it in SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2025 12:04:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142522#M4497</guid>
      <dc:creator>emma_s</dc:creator>
      <dc:date>2025-12-24T12:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Vector search index very slow</title>
      <link>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142532#M4499</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/201196"&gt;@RodrigoE&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Your LATERAL subquery calls the Vector Search function once for every row of the 52M-row table, which results in tens of millions of remote calls to the Vector Search endpoint—this is not a nice pattern and will be extremely slow leading to token expiry and the error that you are encountering.&lt;/P&gt;
&lt;P&gt;If you are trying to do something like "for each of the 1,400 query rows, find the best match among the 52M target rows", my suggestion is to invert the index and the other table.&amp;nbsp;Create the vector index on the large table and drive the query from the small table. That reduces calls from ~52M to ~1,400.&amp;nbsp;This pattern matches the intended “multiple terms at the same time using LATERAL” examples shown in the docs, where the outer (driver) table is small.&lt;BR /&gt;Ref Doc -&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/functions/vector_search" target="_blank"&gt;https://docs.databricks.com/aws/en/sql/language-manual/functions/vector_search&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But if you want to do what you are already doing - "assign each of the 52M rows the best match among the 1,400-row set", then Vector Search might not be the right way.&amp;nbsp;Compute embeddings for both tables and perform a Spark-side nearest-prototype assignment, broadcasting the 1,400 embeddings and computing the argmax similarity per row. This avoids 52M remote queries and keeps compute in Spark. Or invert the problem: index the large table, issue 1,400 Vector Search queries, collect top-1 matches, and post-process if that satisfies your use case.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2025 15:18:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/vector-search-index-very-slow/m-p/142532#M4499</guid>
      <dc:creator>iyashk-DB</dc:creator>
      <dc:date>2025-12-24T15:18:56Z</dc:date>
    </item>
  </channel>
</rss>

