embedding and pgvector query speedup
Wow, I found a very silly issue that was holding back this query. The data is a langchain embedding table of items associated with places, as well as a second table with those place addresses along with their longitude, latitude. Also, as I had a slower query, executed through sqlalchemy, like from sqlalchemy.sql import text with foo.engine.connect() as conn: data = {"vector": [0.06014461815357208, 0.07383278757333755, 0.010295705869793892, -0.058833882212638855,], "longitude": "", "latitude": ""} sql = """ """ statement = text(sql) # TODO also parameterize the `limit 10` ? fetchmany() results = conn.execute(statement, data).mappings().fetchall() I’m glad about three strategies I used to help speed up the debugging. Namely, (1) deconstructing the sqlalchemy code, into a raw SQL query I could play with, (2) using DBeaver to quickly throw my raw SQL query against postgresql, for super fast iteration, and (3) of course using explain analyze to look at query plans to understand where the bottle neck may be. ...