Open rsomani95 opened 5 months ago
@rsomani95 can you try materializing the CTE? such as
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
)
SELECT distances.id, distances.distance, distances.category
FROM distances
-- WHERE distances.distance < 0.99
ORDER BY distances.distance
LIMIT 100
;
@cevian thanks, that seems to do the trick. However, this query seems to not use the index and instead compute distances for all rows. Here's the query plan:
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Limit (cost=27830.23..27830.48 rows=100 width=56) (actual time=3473.009..3473.366 rows=100 loops=1)
CTE distances
-> Hash Join (cost=48.75..11972.34 rows=450000 width=32) (actual time=4.406..2818.668 rows=450000 loops=1)
Hash Cond: (segment.asset_id = asset.id)
-> Seq Scan on segment (cost=0.00..9614.00 rows=450000 width=58) (actual time=0.006..529.056 rows=450000 loops=1)
-> Hash (cost=30.00..30.00 rows=1500 width=16) (actual time=4.370..4.374 rows=1500 loops=1)
Buckets: 2048 Batches: 1 Memory Usage: 87kB
-> Seq Scan on asset (cost=0.00..30.00 rows=1500 width=16) (actual time=0.006..2.165 rows=1500 loops=1)
-> Sort (cost=15857.89..16232.89 rows=150000 width=56) (actual time=3473.005..3473.124 rows=100 loops=1)
Sort Key: distances.distance
Sort Method: top-N heapsort Memory: 37kB
-> CTE Scan on distances (cost=0.00..10125.00 rows=150000 width=56) (actual time=4.868..3465.088 rows=6195 loops=1)
Filter: (distance < '0.99'::double precision)
Rows Removed by Filter: 443805
Planning Time: 0.309 ms
Execution Time: 3476.112 ms
I tried adding ORDER BY
to the CTE query, and while that does use the index and execute faster, it doesn't return ordered results. I need to run ORDER BY distances.distance
after the CTE to get correct results, which runs a lot slower.
Here's what I mean more concretely:
-- Runs fast (~30ms), and uses vector index, but incorrectly ordered results
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
ORDER BY
distance
-- LIMIT 300
)
SELECT distances.id, distances.distance, distances.category
FROM distances
-- WHERE distances.distance < 0.99
-- ORDER BY distances.distance
LIMIT 100
;
-- Runs quite slow (~5800ms)
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
ORDER BY
distance
-- LIMIT 300
)
SELECT distances.id, distances.distance, distances.category
FROM distances
-- WHERE distances.distance < 0.99
ORDER BY distances.distance
LIMIT 100
;
There's a similar issue in pgvecto.rs: https://github.com/tensorchord/pgvecto.rs/issues/502#issuecomment-2174956857
Could the same thing be happening here?
@rsomani95 can you try putting all the order by, where, and limits inside the CTE, with the outer query only doing an ORDER BY distance again? Something like:
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
ORDER BY
distance
LIMIT 100
)
SELECT distances.id, distances.distance, distances.category
FROM distances
ORDER BY distances.distance
;
Thanks
Indexes don't work without limits, so what happen when you keep limit in cte?
-- Runs quite slow (~5800ms)
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
ORDER BY
distance
LIMIT 300
)
SELECT distances.id, distances.distance, distances.category
FROM distances
-- WHERE distances.distance < 0.99
ORDER BY distances.distance
LIMIT 100
;
and also moving WHERE distances.distance < 0.99
to cte? It will create much more bigger query but these two changes did really great job in performance for us.
-- Runs quite slow (~5800ms)
WITH distances AS MATERIALIZED (
SELECT
segment.id, segment.category,
embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]'
AS distance
FROM
segment
INNER JOIN
asset ON segment.asset_id = asset.id
WHERE ( embedding <=> '[0.048492431640625,0.004207611083984375,0.020538330078125,-0.06622314453125,-0.009918212890625,0.0819091796875,-0.0247344970703125,-0.01090240478515625,0.0679931640625,-0.040924072265625,-0.0034122467041015625,0.072021484375,0.0008335113525390625,-0.006832122802734375,0.00824737548828125,-0.03314208984375,0.025909423828125,0.04852294921875,-0.0171661376953125,0.0048370361328125,-0.0230712890625,-0.01190185546875,-0.0043792724609375,0.01007080078125,-0.052276611328125,0.0180816650390625,-0.00858306884765625,0.0078582763671875,-0.050811767578125,0.007328033447265625,0.0712890625,0.033416748046875,-0.03240966796875,-0.0029735565185546875,-0.0399169921875,-0.07537841796875,-0.0631103515625,-0.02191162109375,-0.0292510986328125,0.063232421875,0.093017578125,0.022674560546875,-0.0186920166015625,0.0041046142578125,-0.0300140380859375,-0.0941162109375,0.038970947265625,0.036651611328125,-0.0223388671875,0.002079010009765625,0.00818634033203125,-0.0187225341796875,0.031982421875,-0.01050567626953125,-0.00460052490234375,-0.0517578125,-0.0269317626953125,-0.038055419921875,0.007781982421875,0.038482666015625,-0.05145263671875,0.00878143310546875,0.021575927734375,0.053375244140625,0.0005512237548828125,0.03448486328125,-0.01157379150390625,0.0237274169921875,-0.05712890625,0.099365234375,-0.0019664764404296875,0.056243896484375,-0.00019276142120361328,-0.027069091796875,0.1966552734375,-0.01096343994140625,0.00528717041015625,-0.0244140625,-0.0211944580078125,0.0116424560546875,-0.053863525390625,-0.042266845703125,-0.0241546630859375,0.016571044921875,0.01535797119140625,0.0203704833984375,-0.036376953125,0.029815673828125,-0.048858642578125,-0.027984619140625,0.0044097900390625,0.049072265625,-0.06146240234375,0.002292633056640625,-0.01023101806640625,-0.0404052734375,0.03216552734375,-0.0093536376953125,-0.01009368896484375,0.03692626953125,-0.0257568359375,0.0193939208984375,0.004894256591796875,0.005229949951171875,-0.007106781005859375,0.06427001953125,0.007354736328125,0.050048828125,0.05267333984375,0.044952392578125,-0.0908203125,-0.02679443359375,0.01000213623046875,0.0247955322265625,0.0106658935546875,-0.0261688232421875,0.0207672119140625,0.045806884765625,0.035491943359375,-0.014556884765625,0.0421142578125,-0.045654296875,-0.048065185546875,0.0234832763671875,-0.14111328125,-0.004230499267578125,0.024566650390625,-0.0244293212890625,0.00693511962890625,0.01145172119140625,0.040283203125,-0.06060791015625,0.00921630859375,0.029083251953125,-0.09417724609375,0.028656005859375,-0.00201416015625,0.09478759765625,-0.01023101806640625,0.0249786376953125,0.018310546875,-0.02783203125,-0.022979736328125,-0.032073974609375,-0.0009412765502929688,0.00971221923828125,0.0071563720703125,-0.06329345703125,-0.01146697998046875,0.0149078369140625,0.0007505416870117188,0.01476287841796875,-0.0672607421875,-0.05224609375,-0.004695892333984375,0.006256103515625,0.00579833984375,0.0203704833984375,-0.01812744140625,-0.003818511962890625,0.007167816162109375,0.041107177734375,-0.01318359375,0.01480865478515625,-0.05267333984375,-0.0017557144165039062,0.011199951171875,-0.0153656005859375,0.0550537109375,0.03387451171875,-0.0196990966796875,0.033782958984375,-0.0158233642578125,0.0,0.037567138671875,0.0020351409912109375,-0.0206451416015625,-0.0242767333984375,0.037933349609375,0.03271484375,-0.035003662109375,-0.0303802490234375,-0.0282440185546875,0.0411376953125,0.023040771484375,0.183349609375,0.034759521484375,-0.01788330078125,0.07275390625,-0.025360107421875,0.0416259765625,0.037567138671875,-0.04315185546875,-0.06610107421875,0.001766204833984375,0.06866455078125,0.0164642333984375,-0.014373779296875,-0.033905029296875,-0.01079559326171875,-0.03521728515625,0.07550048828125,-0.01229095458984375,0.0278778076171875,0.039764404296875,-0.046722412109375,-0.0186309814453125,0.033660888671875,0.00748443603515625,0.0007295608520507812,-0.0947265625,0.04132080078125,-0.0140380859375,0.01447296142578125,-0.051544189453125,-0.055419921875,0.02691650390625,0.0095062255859375,-0.01568603515625,0.004299163818359375,-0.041656494140625,-0.0280303955078125,0.07684326171875,0.00970458984375,0.04351806640625,-0.078125,-0.0384521484375,0.0222930908203125,-0.003314971923828125,-0.055999755859375,0.01373291015625,0.01485443115234375,-0.04168701171875,0.04571533203125,-0.04693603515625,-0.0166473388671875,-0.072998046875,-0.0240478515625,0.002040863037109375,0.0220794677734375,-0.0009369850158691406,-0.027069091796875,0.04248046875,-0.0750732421875,-0.0960693359375,-0.03765869140625,-0.0173187255859375,-0.0325927734375,0.050750732421875,-0.052520751953125,-0.038818359375,-0.177001953125,-0.0188751220703125,0.0130462646484375,0.04058837890625,0.042236328125,-0.03338623046875,-0.031982421875,0.04229736328125,-0.05474853515625,0.0287017822265625,0.007640838623046875,-0.033447265625,0.0033664703369140625,-0.055694580078125,-0.0714111328125,-0.036346435546875,0.00142669677734375,-0.03070068359375,0.0299530029296875,-0.03369140625,-0.00966644287109375,0.005718231201171875,0.0187225341796875,-0.0213775634765625,-0.0185546875,-0.04180908203125,-0.0450439453125,-0.0229034423828125,0.04693603515625,0.036163330078125,0.061004638671875,-0.0672607421875,0.0009226799011230469,-0.046600341796875,-0.0242767333984375,-0.058624267578125,-0.1256103515625,0.023223876953125,0.0295867919921875,-0.046234130859375,0.0163421630859375,0.050384521484375,-0.025115966796875,0.037994384765625,0.027984619140625,0.0261383056640625,-0.0117645263671875,-0.004352569580078125,0.00960540771484375,0.07293701171875,0.062225341796875,-0.01007080078125,-0.02685546875,-0.0005059242248535156,-0.0122833251953125,-0.024749755859375,0.036529541015625,-0.03192138671875,0.015869140625,0.0777587890625,0.0109405517578125,-0.050018310546875,0.06787109375,0.08477783203125,-0.035736083984375,0.01482391357421875,0.05218505859375,-0.004047393798828125,-0.0165252685546875,0.1019287109375,-0.04510498046875,0.022186279296875,0.005382537841796875,0.004451751708984375,0.01129913330078125,-0.048980712890625,0.047027587890625,-0.0146026611328125,-0.012939453125,-0.0210418701171875,-0.0308990478515625,-0.057220458984375,0.0005764961242675781,0.01168060302734375,-0.004848480224609375,0.01641845703125,-0.0226898193359375,0.0187835693359375,0.1494140625,0.055328369140625,-0.0178985595703125,-0.0169219970703125,-0.043792724609375,-0.0238800048828125,-0.013580322265625,0.0104522705078125,0.0526123046875,-0.033050537109375,0.00775909423828125,-0.025238037109375,0.00724029541015625,-0.025909423828125,-0.00861358642578125,0.040679931640625,0.1619873046875,0.0263519287109375,-0.0229034423828125,0.0101165771484375,-0.041107177734375,-0.0301361083984375,0.006916046142578125,-0.0175323486328125,0.01502227783203125,-0.0161895751953125,-0.01323699951171875,-0.004383087158203125,-0.0087432861328125,-0.0511474609375,0.00356292724609375,0.011383056640625,-0.0548095703125,-0.039947509765625,0.045318603515625,-0.01392364501953125,-0.01788330078125,0.025634765625,0.00868988037109375,-0.00244903564453125,0.0030956268310546875,0.0032634735107421875,0.06744384765625,0.0064697265625,0.005268096923828125,-0.014190673828125,-0.01392364501953125,0.01105499267578125,0.0307769775390625,-0.017425537109375,0.002033233642578125,0.034698486328125,-0.0250244140625,-0.00201416015625,-0.0233154296875,-0.019287109375,0.0181884765625,0.008575439453125,-0.03564453125,0.045379638671875,0.003162384033203125,0.0053863525390625,0.011322021484375,-0.01247406005859375,-0.04608154296875,0.02166748046875,0.0238189697265625,0.022125244140625,0.0035915374755859375,0.022064208984375,0.00432586669921875,-0.03546142578125,0.01241302490234375,0.02740478515625,0.004619598388671875,-0.09027099609375,-0.052764892578125,0.0325927734375,-0.02593994140625,0.0094146728515625,-0.01071929931640625,0.01453399658203125,0.00960540771484375,0.05364990234375,0.003635406494140625,-0.020416259765625,-0.0279083251953125,-0.004726409912109375,-0.007053375244140625,0.004291534423828125,-0.00629425048828125,-0.0200958251953125,-0.049163818359375,0.02899169921875,-0.06494140625,-0.0117034912109375,-0.04913330078125,0.0148468017578125,-0.070556640625,0.04052734375,0.0009059906005859375,0.021759033203125,-0.0352783203125,-0.0341796875,-0.050262451171875,0.00033593177795410156,0.043792724609375,-0.024658203125,0.0182952880859375,-0.01245880126953125,-0.01078033447265625,-0.0157012939453125,0.045257568359375,0.0224609375,-0.0308074951171875,0.06298828125,0.0051727294921875,0.00559234619140625,-0.025604248046875,-0.0242919921875,0.01508331298828125,-0.01375579833984375,0.0262298583984375,-0.043365478515625,-0.032958984375,-0.0101776123046875,-0.0250244140625,-0.0118408203125,0.0208282470703125,-0.006626129150390625,0.047698974609375,0.0027217864990234375,-0.023956298828125,-0.0016622543334960938,0.051513671875,-0.001529693603515625,-0.0250396728515625,-0.0016460418701171875,-0.0206451416015625,0.047576904296875,-0.06134033203125,0.03338623046875,-0.0251922607421875,0.17041015625,0.04351806640625,-0.07464599609375,0.03369140625,1.4543533325195312e-05,-0.0011463165283203125,-0.048004150390625,0.00016164779663085938,0.0247344970703125,-0.0215301513671875,0.03076171875,-0.016937255859375,-0.0943603515625,-0.026824951171875,0.01163482666015625,0.039276123046875,-0.01502227783203125,0.00400543212890625,0.01165771484375,0.0169677734375,-0.033050537109375,-0.03863525390625,-0.09918212890625,0.04339599609375,-0.04229736328125,-0.005825042724609375,-0.030731201171875,-0.0289306640625,0.0068206787109375,0.0158538818359375,0.043853759765625,0.005344390869140625,-0.0231170654296875,0.0287017822265625,0.01654052734375,0.041961669921875,0.005596160888671875,0.0307769775390625,0.0102081298828125,0.03472900390625,0.0164337158203125,0.00878143310546875,0.061492919921875,-0.0435791015625,-0.08380126953125,0.0120391845703125,-0.020660400390625,-0.049346923828125,0.03900146484375,-0.03497314453125,0.00788116455078125,-0.053192138671875,0.0191497802734375,0.02227783203125,0.0333251953125,-0.00919342041015625,-0.104248046875,-0.049774169921875,-0.0645751953125,0.028350830078125,-0.03839111328125,-0.01654052734375,-0.00263214111328125,-0.007259368896484375,0.017120361328125,-0.00391387939453125,-0.0848388671875,0.006214141845703125,-0.0175018310546875,-0.051971435546875,-0.048828125,-0.08807373046875,0.00550079345703125,0.030303955078125,0.00983428955078125,-0.0084686279296875,0.01213836669921875,0.01532745361328125,0.003978729248046875,0.03924560546875,-0.02044677734375,0.0391845703125,-0.051513671875,-0.02532958984375,-0.0233612060546875,0.03936767578125,-0.0286712646484375,-0.037811279296875,0.05712890625,0.0418701171875,0.0294036865234375,0.006137847900390625,-0.0252532958984375,0.003887176513671875,-0.0084991455078125,0.003604888916015625,-0.01824951171875,0.04150390625,-0.08380126953125,-0.00284576416015625,0.01535797119140625,0.0009307861328125,-0.00376129150390625,0.01319122314453125,-0.057586669921875,0.0261383056640625,0.01068878173828125,0.0295867919921875,-0.00908660888671875,-0.0201873779296875,-0.01419830322265625,0.0159149169921875,0.06597900390625,-0.0137176513671875,0.014495849609375,0.01540374755859375,0.01279449462890625,-0.0262298583984375,-0.0182952880859375,0.04644775390625,-0.00547027587890625,-0.0021648406982421875,-0.03570556640625,-0.04400634765625,0.00457000732421875,0.01441192626953125,0.0352783203125,0.043182373046875,-0.0010404586791992188,-0.032196044921875,-0.0079345703125,-0.043792724609375,-0.016204833984375,0.05029296875,0.004558563232421875,-0.055328369140625,-0.0265960693359375,0.028350830078125,0.03192138671875,0.029693603515625,0.040435791015625,0.004878997802734375,-0.034515380859375,0.025146484375,-0.01326751708984375,-0.0140838623046875,-0.0008788108825683594,-0.0230865478515625,0.0088653564453125,0.00522613525390625,-0.0179290771484375,0.0303802490234375,0.032928466796875,-0.0184326171875,0.033935546875,-0.002887725830078125,-0.0090484619140625,0.0176849365234375]') < 0.99
ORDER BY
distance
LIMIT 300
)
SELECT distances.id, distances.distance, distances.category
FROM distances
ORDER BY distances.distance
LIMIT 100
;
and not sure if you need both ORDER BY
I had a chance to install pgvectorscale into my Django project, and was able to use the Django ORM to do the right query (as opposed to my attempts at hand writing them in an isolated test DB above). This query uses the index, gives me the correct results and runs pretty fast (~10-30ms, depending on search params):
SELECT "segment"."id",
("segment"."embedding" <=> '[0.049652099609375,-0.0312042236328125,0.05072021484375,0.044769287109375,-0.0245819091796875,-0.019439697265625,-0.033538818359375,0.08111572265625,-0.03460693359375,0.0262451171875,0.0012063980102539062,0.0252685546875,0.03680419921875,-0.0185394287109375,-0.0006055831909179688,-0.0137481689453125,0.0162353515625,-0.0116424560546875,-0.01605224609375,-0.0192413330078125,0.053009033203125,0.05615234375,0.03668212890625,-0.0142059326171875,-0.00839996337890625,-0.01143646240234375,-0.0050506591796875,0.0108642578125,0.0626220703125,0.027099609375,0.0020732879638671875,0.0249786376953125,-0.0011377334594726562,0.037689208984375,-0.0335693359375,-0.0279693603515625,0.0026035308837890625,-0.02587890625,0.0059356689453125,0.0150909423828125,-0.002193450927734375,-0.006198883056640625,0.016448974609375,0.031646728515625,0.00965118408203125,0.07879638671875,0.0265045166015625,0.0258636474609375,0.002086639404296875,-0.00040221214294433594,-0.0012149810791015625,0.03631591796875,0.0311431884765625,-0.009613037109375,0.0526123046875,-0.035247802734375,-0.003124237060546875,0.027191162109375,-0.023529052734375,0.019439697265625,-0.0206451416015625,-0.0029125213623046875,-0.04638671875,-0.03009033203125,0.00909423828125,0.0079345703125,-0.0125579833984375,-0.0246429443359375,-0.0004260540008544922,-0.039581298828125,0.0205078125,-0.009552001953125,0.0186004638671875,-0.020538330078125,-0.08184814453125,0.0318603515625,-0.003688812255859375,-0.06683349609375,0.0863037109375,-0.00484466552734375,0.018798828125,-0.040924072265625,-0.01146697998046875,0.005062103271484375,0.00647735595703125,0.007568359375,-0.1455078125,-0.0287322998046875,0.0245361328125,0.05853271484375,0.0655517578125,-0.037689208984375,-0.02301025390625,0.036102294921875,-0.005474090576171875,-0.02703857421875,-0.0235137939453125,0.01412200927734375,0.05120849609375,-0.006237030029296875,0.031890869140625,-0.06561279296875,0.0014162063598632812,0.0307464599609375,-0.037506103515625,0.0109100341796875,0.009918212890625,-0.053436279296875,0.022186279296875,-0.0733642578125,-0.0599365234375,0.0240631103515625,0.0217132568359375,0.032684326171875,-0.048919677734375,0.040313720703125,0.03778076171875,0.0222015380859375,0.0190277099609375,0.0022487640380859375,-0.01480865478515625,0.033843994140625,0.030853271484375,0.041290283203125,-0.447265625,0.01080322265625,0.0216827392578125,0.02740478515625,-0.004116058349609375,0.007801055908203125,-0.0022125244140625,-0.0155029296875,0.006683349609375,-0.0211181640625,-0.045562744140625,0.01499176025390625,0.01056671142578125,-0.054931640625,0.024749755859375,-0.0303955078125,0.0247802734375,-0.0506591796875,-0.043914794921875,0.040191650390625,0.014556884765625,0.01904296875,-0.048126220703125,0.006107330322265625,0.050994873046875,0.02093505859375,-0.036376953125,0.030029296875,0.008758544921875,-0.0024547576904296875,-0.0097198486328125,-0.01413726806640625,-0.00847625732421875,0.042755126953125,-0.0023212432861328125,-0.07275390625,0.00750732421875,0.01221466064453125,0.00324249267578125,-0.06768798828125,-0.023101806640625,-0.04083251953125,-0.01441192626953125,0.005580902099609375,0.0188446044921875,-0.001522064208984375,0.0091094970703125,-0.031341552734375,-0.0443115234375,-0.0289154052734375,-0.0224761962890625,-0.0074920654296875,-0.01119232177734375,-0.0302886962890625,-0.0060577392578125,-0.0034961700439453125,0.0260009765625,-0.06304931640625,0.0219268798828125,0.00836181640625,0.0699462890625,0.1837158203125,0.006381988525390625,0.0011262893676757812,0.02728271484375,-0.005809783935546875,0.0142822265625,-0.012847900390625,-0.0701904296875,-0.0158843994140625,0.021575927734375,0.0003437995910644531,-0.0293426513671875,0.00228118896484375,0.005889892578125,-0.02288818359375,0.0027103424072265625,0.060546875,-0.0273895263671875,0.0606689453125,0.0176849365234375,0.0167999267578125,-0.04534912109375,0.0177001953125,-0.028656005859375,-0.04168701171875,0.053466796875,-0.00994110107421875,0.0304718017578125,-0.040130615234375,-0.005035400390625,-0.006687164306640625,-0.02783203125,0.00470733642578125,-0.0197601318359375,0.0154266357421875,-0.0843505859375,0.02740478515625,-0.01525115966796875,0.00537109375,-0.0140380859375,0.0162200927734375,0.0014514923095703125,0.0206756591796875,0.0038127899169921875,-0.00711822509765625,0.005886077880859375,0.06524658203125,-0.02899169921875,-0.03485107421875,0.010986328125,0.050872802734375,0.1207275390625,-0.0063934326171875,-0.032318115234375,0.0054931640625,-0.00988006591796875,0.016510009765625,-0.060333251953125,0.05511474609375,0.0271759033203125,0.04632568359375,-0.019317626953125,-0.01056671142578125,0.01305389404296875,-0.0157623291015625,0.00023567676544189453,-0.05694580078125,0.034698486328125,-0.020172119140625,-0.0171051025390625,-0.0151214599609375,0.0298309326171875,0.00222015380859375,0.01006317138671875,-0.024566650390625,-0.0185089111328125,-0.007297515869140625,0.0005364418029785156,-0.0211639404296875,-0.03173828125,0.0198974609375,0.049896240234375,0.048095703125,-0.00287628173828125,-0.0131378173828125,0.0025768280029296875,0.0050048828125,0.01381683349609375,0.0120391845703125,-0.0010232925415039062,-0.01129150390625,-0.038848876953125,-0.0240020751953125,-0.08892822265625,0.0032329559326171875,-0.08489990234375,-0.004558563232421875,0.04443359375,0.06121826171875,-0.004360198974609375,-0.0263519287109375,-0.0293426513671875,-0.0928955078125,-0.00826263427734375,-0.004817962646484375,-0.0189971923828125,-0.0015592575073242188,-0.030792236328125,0.00870513916015625,-0.03948974609375,0.005161285400390625,-0.022552490234375,-0.0157470703125,-0.014495849609375,-0.022613525390625,-0.014251708984375,0.020294189453125,0.0430908203125,0.0301361083984375,-0.00597381591796875,-0.03619384765625,0.007122039794921875,0.00995635986328125,0.0194244384765625,0.01837158203125,0.0673828125,-0.0023822784423828125,-0.054595947265625,0.01953125,0.03326416015625,-0.0413818359375,0.0086822509765625,-0.0511474609375,0.043731689453125,0.044036865234375,0.1800537109375,0.0274658203125,-0.007495880126953125,-0.01047515869140625,-0.00174713134765625,0.00928497314453125,0.03759765625,0.0313720703125,-0.03033447265625,0.0277557373046875,-0.028564453125,-0.00865936279296875,0.02032470703125,-0.0085906982421875,0.06524658203125,0.0012998580932617188,-0.00621795654296875,-0.00665283203125,0.02728271484375,-0.02374267578125,-0.00096893310546875,-0.0255584716796875,0.03729248046875,-0.00769805908203125,-0.0234832763671875,-0.0164642333984375,-0.0008974075317382812,0.01207733154296875,0.027618408203125,0.036895751953125,-0.01068878173828125,0.0028934478759765625,-0.08319091796875,0.032257080078125,-0.057220458984375,-0.093994140625,0.03533935546875,0.0016889572143554688,0.003925323486328125,-0.039337158203125,-0.04876708984375,0.0193939208984375,-0.02032470703125,-0.033203125,-0.00930023193359375,-0.0213623046875,0.01275634765625,-0.043121337890625,-0.018707275390625,-0.006359100341796875,-0.034820556640625,-0.020599365234375,0.0330810546875,-0.007274627685546875,-0.0517578125,0.01210784912109375,0.038970947265625,0.0082855224609375,0.06353759765625,-0.0014314651489257812,0.0399169921875,0.007720947265625,0.00601959228515625,-0.0181121826171875,-0.005985260009765625,-0.0246734619140625,-0.0189361572265625,0.00768280029296875,0.056427001953125,0.01324462890625,0.0118865966796875,0.042083740234375,-0.056488037109375,0.02032470703125,0.021087646484375,0.07708740234375,0.0193634033203125,0.044586181640625,-0.035125732421875,0.0130615234375,-0.01395416259765625,-0.00783538818359375,0.00699615478515625,0.015594482421875,-0.0294647216796875,0.044219970703125,0.0018186569213867188,-0.03887939453125,-0.06207275390625,0.0205078125,-0.0120391845703125,-0.060699462890625,0.062225341796875,0.0225830078125,-0.039031982421875,0.038299560546875,0.043121337890625,-0.0091400146484375,0.0193634033203125,0.003223419189453125,0.06549072265625,0.0259552001953125,0.0013971328735351562,0.02764892578125,0.004016876220703125,0.002330780029296875,0.0221405029296875,-0.047119140625,-0.01313018798828125,-0.007007598876953125,0.0484619140625,-0.0206756591796875,-0.02984619140625,0.050140380859375,-0.024566650390625,-0.07000732421875,0.00817108154296875,0.0044708251953125,0.0079803466796875,-0.02081298828125,-0.025299072265625,0.0020236968994140625,0.06451416015625,-0.033721923828125,0.03924560546875,-0.034820556640625,-0.0251007080078125,-0.0197906494140625,0.03204345703125,-0.052032470703125,-0.021881103515625,0.027130126953125,0.015655517578125,0.01788330078125,0.002227783203125,0.0311431884765625,-0.025054931640625,0.036712646484375,0.036376953125,0.0197906494140625,-0.01401519775390625,-0.01239013671875,0.0211181640625,0.017608642578125,-0.0411376953125,-0.003086090087890625,-0.030426025390625,0.0419921875,0.024993896484375,0.00704193115234375,0.0174102783203125,-0.046600341796875,0.0240020751953125,-0.003147125244140625,-0.035919189453125,0.0145111083984375,-0.1260986328125,-0.055755615234375,0.015045166015625,-0.01503753662109375,0.0247955322265625,-0.01526641845703125,-0.08917236328125,0.0280609130859375,-0.125,-0.015625,0.0158233642578125,-0.05902099609375,0.044830322265625,0.040435791015625,-0.075439453125,-0.008148193359375,0.026611328125,0.05792236328125,-0.038818359375,-0.039642333984375,-0.044189453125,0.03759765625,0.019287109375,0.003475189208984375,0.01641845703125,0.03753662109375,-0.036651611328125,-0.042449951171875,-0.003643035888671875,0.09735107421875,-0.01352691650390625,0.00959014892578125,0.01910400390625,0.0169830322265625,0.100341796875,-0.03302001953125,0.0285797119140625,0.027313232421875,0.06903076171875,0.0022296905517578125,-0.0196533203125,-0.055633544921875,0.01241302490234375,0.0255584716796875,0.040313720703125,0.0177001953125,-0.016937255859375,-0.03033447265625,-0.004016876220703125,-0.028472900390625,0.0011377334594726562,-0.0013475418090820312,0.0239105224609375,-0.0189971923828125,-0.039398193359375,-0.005588531494140625,0.0265960693359375,-0.0364990234375,-0.006343841552734375,-0.0036144256591796875,-0.0501708984375,0.04541015625,-0.046875,-0.0245513916015625,0.0148468017578125,-0.043853759765625,-0.04522705078125,-0.0379638671875,-0.004241943359375,-0.0107421875,0.07000732421875,0.0219573974609375,-0.0095062255859375,0.010711669921875,-0.0281524658203125,-0.025604248046875,-0.0443115234375,-0.039276123046875,-0.00286102294921875,-0.047088623046875,-0.0196685791015625,0.0127410888671875,0.0282745361328125,0.0291748046875,-0.0013494491577148438,-0.0008282661437988281,-0.00018167495727539062,0.0152435302734375,-0.01043701171875,0.00948333740234375,-0.06524658203125,-0.032928466796875,0.0772705078125,-0.046844482421875,-0.02008056640625,-0.025482177734375,0.010650634765625,-0.002315521240234375,-0.0282440185546875,0.0095672607421875,0.0008044242858886719,-0.0118408203125,-0.037841796875,0.04351806640625,-0.0889892578125,-0.0626220703125,-0.037811279296875,0.0137176513671875,0.005069732666015625,0.01271820068359375,-0.0038623809814453125,0.0079345703125,0.06689453125,0.00689697265625,0.022216796875,-0.0033512115478515625,-0.010101318359375,0.0225982666015625,-0.00457763671875,-0.02032470703125,0.007251739501953125,0.039642333984375,-0.01200103759765625,0.08294677734375,-0.01001739501953125,-0.02447509765625,0.0189208984375,-0.01495361328125,0.0462646484375,0.0189361572265625,-0.01678466796875,0.055267333984375,0.01495361328125,-0.008331298828125,-0.02435302734375,-0.0144805908203125,0.025634765625,-0.0025005340576171875,-0.037078857421875,0.0416259765625,-0.029815673828125,-0.005767822265625,-0.01434326171875,0.0352783203125,-0.01287841796875,-0.01349639892578125,-0.0204010009765625,-0.01009368896484375,-0.033538818359375,0.049346923828125,-0.045501708984375,0.020355224609375,0.004547119140625,-0.01039886474609375,-0.027069091796875,0.014373779296875,0.0003654956817626953,-0.0135345458984375,-0.05413818359375,-0.022979736328125,-0.01458740234375,-0.0243988037109375,-0.0012149810791015625,-0.044219970703125]')
AS "distance"
FROM "segment"
INNER JOIN "asset"
ON ("segment"."asset_id" = "asset"."id")
WHERE ("asset"."user_id" = '...'::uuid AND "asset"."library_id" = '...'::uuid AND "segment"."category" IN ('category_a') AND ("segment"."embedding" <=> '[0.049652099609375,-0.0312042236328125,0.05072021484375,0.044769287109375,-0.0245819091796875,-0.019439697265625,-0.033538818359375,0.08111572265625,-0.03460693359375,0.0262451171875,0.0012063980102539062,0.0252685546875,0.03680419921875,-0.0185394287109375,-0.0006055831909179688,-0.0137481689453125,0.0162353515625,-0.0116424560546875,-0.01605224609375,-0.0192413330078125,0.053009033203125,0.05615234375,0.03668212890625,-0.0142059326171875,-0.00839996337890625,-0.01143646240234375,-0.0050506591796875,0.0108642578125,0.0626220703125,0.027099609375,0.0020732879638671875,0.0249786376953125,-0.0011377334594726562,0.037689208984375,-0.0335693359375,-0.0279693603515625,0.0026035308837890625,-0.02587890625,0.0059356689453125,0.0150909423828125,-0.002193450927734375,-0.006198883056640625,0.016448974609375,0.031646728515625,0.00965118408203125,0.07879638671875,0.0265045166015625,0.0258636474609375,0.002086639404296875,-0.00040221214294433594,-0.0012149810791015625,0.03631591796875,0.0311431884765625,-0.009613037109375,0.0526123046875,-0.035247802734375,-0.003124237060546875,0.027191162109375,-0.023529052734375,0.019439697265625,-0.0206451416015625,-0.0029125213623046875,-0.04638671875,-0.03009033203125,0.00909423828125,0.0079345703125,-0.0125579833984375,-0.0246429443359375,-0.0004260540008544922,-0.039581298828125,0.0205078125,-0.009552001953125,0.0186004638671875,-0.020538330078125,-0.08184814453125,0.0318603515625,-0.003688812255859375,-0.06683349609375,0.0863037109375,-0.00484466552734375,0.018798828125,-0.040924072265625,-0.01146697998046875,0.005062103271484375,0.00647735595703125,0.007568359375,-0.1455078125,-0.0287322998046875,0.0245361328125,0.05853271484375,0.0655517578125,-0.037689208984375,-0.02301025390625,0.036102294921875,-0.005474090576171875,-0.02703857421875,-0.0235137939453125,0.01412200927734375,0.05120849609375,-0.006237030029296875,0.031890869140625,-0.06561279296875,0.0014162063598632812,0.0307464599609375,-0.037506103515625,0.0109100341796875,0.009918212890625,-0.053436279296875,0.022186279296875,-0.0733642578125,-0.0599365234375,0.0240631103515625,0.0217132568359375,0.032684326171875,-0.048919677734375,0.040313720703125,0.03778076171875,0.0222015380859375,0.0190277099609375,0.0022487640380859375,-0.01480865478515625,0.033843994140625,0.030853271484375,0.041290283203125,-0.447265625,0.01080322265625,0.0216827392578125,0.02740478515625,-0.004116058349609375,0.007801055908203125,-0.0022125244140625,-0.0155029296875,0.006683349609375,-0.0211181640625,-0.045562744140625,0.01499176025390625,0.01056671142578125,-0.054931640625,0.024749755859375,-0.0303955078125,0.0247802734375,-0.0506591796875,-0.043914794921875,0.040191650390625,0.014556884765625,0.01904296875,-0.048126220703125,0.006107330322265625,0.050994873046875,0.02093505859375,-0.036376953125,0.030029296875,0.008758544921875,-0.0024547576904296875,-0.0097198486328125,-0.01413726806640625,-0.00847625732421875,0.042755126953125,-0.0023212432861328125,-0.07275390625,0.00750732421875,0.01221466064453125,0.00324249267578125,-0.06768798828125,-0.023101806640625,-0.04083251953125,-0.01441192626953125,0.005580902099609375,0.0188446044921875,-0.001522064208984375,0.0091094970703125,-0.031341552734375,-0.0443115234375,-0.0289154052734375,-0.0224761962890625,-0.0074920654296875,-0.01119232177734375,-0.0302886962890625,-0.0060577392578125,-0.0034961700439453125,0.0260009765625,-0.06304931640625,0.0219268798828125,0.00836181640625,0.0699462890625,0.1837158203125,0.006381988525390625,0.0011262893676757812,0.02728271484375,-0.005809783935546875,0.0142822265625,-0.012847900390625,-0.0701904296875,-0.0158843994140625,0.021575927734375,0.0003437995910644531,-0.0293426513671875,0.00228118896484375,0.005889892578125,-0.02288818359375,0.0027103424072265625,0.060546875,-0.0273895263671875,0.0606689453125,0.0176849365234375,0.0167999267578125,-0.04534912109375,0.0177001953125,-0.028656005859375,-0.04168701171875,0.053466796875,-0.00994110107421875,0.0304718017578125,-0.040130615234375,-0.005035400390625,-0.006687164306640625,-0.02783203125,0.00470733642578125,-0.0197601318359375,0.0154266357421875,-0.0843505859375,0.02740478515625,-0.01525115966796875,0.00537109375,-0.0140380859375,0.0162200927734375,0.0014514923095703125,0.0206756591796875,0.0038127899169921875,-0.00711822509765625,0.005886077880859375,0.06524658203125,-0.02899169921875,-0.03485107421875,0.010986328125,0.050872802734375,0.1207275390625,-0.0063934326171875,-0.032318115234375,0.0054931640625,-0.00988006591796875,0.016510009765625,-0.060333251953125,0.05511474609375,0.0271759033203125,0.04632568359375,-0.019317626953125,-0.01056671142578125,0.01305389404296875,-0.0157623291015625,0.00023567676544189453,-0.05694580078125,0.034698486328125,-0.020172119140625,-0.0171051025390625,-0.0151214599609375,0.0298309326171875,0.00222015380859375,0.01006317138671875,-0.024566650390625,-0.0185089111328125,-0.007297515869140625,0.0005364418029785156,-0.0211639404296875,-0.03173828125,0.0198974609375,0.049896240234375,0.048095703125,-0.00287628173828125,-0.0131378173828125,0.0025768280029296875,0.0050048828125,0.01381683349609375,0.0120391845703125,-0.0010232925415039062,-0.01129150390625,-0.038848876953125,-0.0240020751953125,-0.08892822265625,0.0032329559326171875,-0.08489990234375,-0.004558563232421875,0.04443359375,0.06121826171875,-0.004360198974609375,-0.0263519287109375,-0.0293426513671875,-0.0928955078125,-0.00826263427734375,-0.004817962646484375,-0.0189971923828125,-0.0015592575073242188,-0.030792236328125,0.00870513916015625,-0.03948974609375,0.005161285400390625,-0.022552490234375,-0.0157470703125,-0.014495849609375,-0.022613525390625,-0.014251708984375,0.020294189453125,0.0430908203125,0.0301361083984375,-0.00597381591796875,-0.03619384765625,0.007122039794921875,0.00995635986328125,0.0194244384765625,0.01837158203125,0.0673828125,-0.0023822784423828125,-0.054595947265625,0.01953125,0.03326416015625,-0.0413818359375,0.0086822509765625,-0.0511474609375,0.043731689453125,0.044036865234375,0.1800537109375,0.0274658203125,-0.007495880126953125,-0.01047515869140625,-0.00174713134765625,0.00928497314453125,0.03759765625,0.0313720703125,-0.03033447265625,0.0277557373046875,-0.028564453125,-0.00865936279296875,0.02032470703125,-0.0085906982421875,0.06524658203125,0.0012998580932617188,-0.00621795654296875,-0.00665283203125,0.02728271484375,-0.02374267578125,-0.00096893310546875,-0.0255584716796875,0.03729248046875,-0.00769805908203125,-0.0234832763671875,-0.0164642333984375,-0.0008974075317382812,0.01207733154296875,0.027618408203125,0.036895751953125,-0.01068878173828125,0.0028934478759765625,-0.08319091796875,0.032257080078125,-0.057220458984375,-0.093994140625,0.03533935546875,0.0016889572143554688,0.003925323486328125,-0.039337158203125,-0.04876708984375,0.0193939208984375,-0.02032470703125,-0.033203125,-0.00930023193359375,-0.0213623046875,0.01275634765625,-0.043121337890625,-0.018707275390625,-0.006359100341796875,-0.034820556640625,-0.020599365234375,0.0330810546875,-0.007274627685546875,-0.0517578125,0.01210784912109375,0.038970947265625,0.0082855224609375,0.06353759765625,-0.0014314651489257812,0.0399169921875,0.007720947265625,0.00601959228515625,-0.0181121826171875,-0.005985260009765625,-0.0246734619140625,-0.0189361572265625,0.00768280029296875,0.056427001953125,0.01324462890625,0.0118865966796875,0.042083740234375,-0.056488037109375,0.02032470703125,0.021087646484375,0.07708740234375,0.0193634033203125,0.044586181640625,-0.035125732421875,0.0130615234375,-0.01395416259765625,-0.00783538818359375,0.00699615478515625,0.015594482421875,-0.0294647216796875,0.044219970703125,0.0018186569213867188,-0.03887939453125,-0.06207275390625,0.0205078125,-0.0120391845703125,-0.060699462890625,0.062225341796875,0.0225830078125,-0.039031982421875,0.038299560546875,0.043121337890625,-0.0091400146484375,0.0193634033203125,0.003223419189453125,0.06549072265625,0.0259552001953125,0.0013971328735351562,0.02764892578125,0.004016876220703125,0.002330780029296875,0.0221405029296875,-0.047119140625,-0.01313018798828125,-0.007007598876953125,0.0484619140625,-0.0206756591796875,-0.02984619140625,0.050140380859375,-0.024566650390625,-0.07000732421875,0.00817108154296875,0.0044708251953125,0.0079803466796875,-0.02081298828125,-0.025299072265625,0.0020236968994140625,0.06451416015625,-0.033721923828125,0.03924560546875,-0.034820556640625,-0.0251007080078125,-0.0197906494140625,0.03204345703125,-0.052032470703125,-0.021881103515625,0.027130126953125,0.015655517578125,0.01788330078125,0.002227783203125,0.0311431884765625,-0.025054931640625,0.036712646484375,0.036376953125,0.0197906494140625,-0.01401519775390625,-0.01239013671875,0.0211181640625,0.017608642578125,-0.0411376953125,-0.003086090087890625,-0.030426025390625,0.0419921875,0.024993896484375,0.00704193115234375,0.0174102783203125,-0.046600341796875,0.0240020751953125,-0.003147125244140625,-0.035919189453125,0.0145111083984375,-0.1260986328125,-0.055755615234375,0.015045166015625,-0.01503753662109375,0.0247955322265625,-0.01526641845703125,-0.08917236328125,0.0280609130859375,-0.125,-0.015625,0.0158233642578125,-0.05902099609375,0.044830322265625,0.040435791015625,-0.075439453125,-0.008148193359375,0.026611328125,0.05792236328125,-0.038818359375,-0.039642333984375,-0.044189453125,0.03759765625,0.019287109375,0.003475189208984375,0.01641845703125,0.03753662109375,-0.036651611328125,-0.042449951171875,-0.003643035888671875,0.09735107421875,-0.01352691650390625,0.00959014892578125,0.01910400390625,0.0169830322265625,0.100341796875,-0.03302001953125,0.0285797119140625,0.027313232421875,0.06903076171875,0.0022296905517578125,-0.0196533203125,-0.055633544921875,0.01241302490234375,0.0255584716796875,0.040313720703125,0.0177001953125,-0.016937255859375,-0.03033447265625,-0.004016876220703125,-0.028472900390625,0.0011377334594726562,-0.0013475418090820312,0.0239105224609375,-0.0189971923828125,-0.039398193359375,-0.005588531494140625,0.0265960693359375,-0.0364990234375,-0.006343841552734375,-0.0036144256591796875,-0.0501708984375,0.04541015625,-0.046875,-0.0245513916015625,0.0148468017578125,-0.043853759765625,-0.04522705078125,-0.0379638671875,-0.004241943359375,-0.0107421875,0.07000732421875,0.0219573974609375,-0.0095062255859375,0.010711669921875,-0.0281524658203125,-0.025604248046875,-0.0443115234375,-0.039276123046875,-0.00286102294921875,-0.047088623046875,-0.0196685791015625,0.0127410888671875,0.0282745361328125,0.0291748046875,-0.0013494491577148438,-0.0008282661437988281,-0.00018167495727539062,0.0152435302734375,-0.01043701171875,0.00948333740234375,-0.06524658203125,-0.032928466796875,0.0772705078125,-0.046844482421875,-0.02008056640625,-0.025482177734375,0.010650634765625,-0.002315521240234375,-0.0282440185546875,0.0095672607421875,0.0008044242858886719,-0.0118408203125,-0.037841796875,0.04351806640625,-0.0889892578125,-0.0626220703125,-0.037811279296875,0.0137176513671875,0.005069732666015625,0.01271820068359375,-0.0038623809814453125,0.0079345703125,0.06689453125,0.00689697265625,0.022216796875,-0.0033512115478515625,-0.010101318359375,0.0225982666015625,-0.00457763671875,-0.02032470703125,0.007251739501953125,0.039642333984375,-0.01200103759765625,0.08294677734375,-0.01001739501953125,-0.02447509765625,0.0189208984375,-0.01495361328125,0.0462646484375,0.0189361572265625,-0.01678466796875,0.055267333984375,0.01495361328125,-0.008331298828125,-0.02435302734375,-0.0144805908203125,0.025634765625,-0.0025005340576171875,-0.037078857421875,0.0416259765625,-0.029815673828125,-0.005767822265625,-0.01434326171875,0.0352783203125,-0.01287841796875,-0.01349639892578125,-0.0204010009765625,-0.01009368896484375,-0.033538818359375,0.049346923828125,-0.045501708984375,0.020355224609375,0.004547119140625,-0.01039886474609375,-0.027069091796875,0.014373779296875,0.0003654956817626953,-0.0135345458984375,-0.05413818359375,-0.022979736328125,-0.01458740234375,-0.0243988037109375,-0.0012149810791015625,-0.044219970703125]') < 0.6)
ORDER BY 2 ASC
LIMIT 100
I have noticed the same issue. No matter what I do, the top 2 results (at least) are unordered. Example (ORDER BY distance LIMIT 3)
0.6016618250810005 0.5856051692005884 0.8335382242753239
I have noticed the same issue. No matter what I do, the top 2 results (at least) are unordered. Example (ORDER BY distance LIMIT 3)
0.6016618250810005 0.5856051692005884 0.8335382242753239
can you show use your query?
I have noticed the same issue. No matter what I do, the top 2 results (at least) are unordered. Example (ORDER BY distance LIMIT 3) 0.6016618250810005 0.5856051692005884 0.8335382242753239
can you show use your query?
select
metadata,
(embedding <=> '[0.09586733, 0.020719072, 0.008679507, 0.04053912, 0.029493852, 0.034695935, -0.038164925, -0.007715375, 0.00082406483, -0.07208916, -0.016678622, -0.067358784, -0.08771782, -0.014110702, -0.02377782, -0.052753482, -0.0037526954, -0.0113868285, 0.06701236, 0.082030304, 0.033324923, 0.093905635, -0.034374002, -0.008801046, -0.026642114, -0.002762966, 0.0609442, -0.0038941926, 0.03911835, 0.005833535, 0.0004561665, -0.030606207, 0.0064804074, -0.08012132, 0.017767383, -0.07288163, 0.001515649, -0.0066404603, 0.036174186, -0.020761, 0.017364096, 0.035605706, 0.06314377, 0.03168773, -0.07710992, -0.07111517, 0.0143547915, 0.0421142, 0.056305744, 0.048123606, 0.07525468, -0.03223762, 0.062167134, -0.004322558, 0.006259412, -0.095755, 0.0098649515, 0.018187528, 0.08179606, 0.016372044, 0.052032676, 0.009867887, -0.027815543, 0.036073975, 0.0032286383, -0.009313007, 0.005308925, 0.015983678, -0.009059775, -0.03467183, -0.0022054543, -0.06798947, -0.04824895, 0.0010600855, 0.016226208, 0.046697166, -0.03190383, -0.025300141, -0.00923171, 0.091186605, -0.094301134, 0.010725623, -0.017742964, 0.054561447, 0.02210865, 0.017100083, -0.018569592, 0.08064499, -0.025246637, 0.01297025, 0.019634726, -0.08295318, 0.07088723, 0.029289663, -0.06765603, -0.016672019, 0.052939706, -0.0291091, 0.05371895, -0.03779324, 0.003658402, -0.06479807, 0.03345208, 0.009355975, 0.00059198966, -0.048140295, -0.035765402, -0.05490253, -0.04815098, -0.029737674, -0.023837997, 0.039791495, -0.040835164, -0.04004522, -0.05021429, 0.0057411594, -0.06387218, -0.031440724, -0.007076972, -0.008084073, -0.020956611, 0.012363419, -0.0121835675, 0.027868154, -0.026674047, 0.0032306476, -0.018214678, 0.051362935, -0.0034128535, -0.05507798, 0.00018701599, -0.057476833, -0.063873775, 0.04288387, -0.0955106, -0.09145135, 0.026485203, -0.015741862, -0.06441315, 0.0401192, 0.062290892, -0.051265422, -0.031124461, -0.07071783, -0.058696177, -0.018623589, 0.08783113, -0.008961007, -0.055737875, -0.04217277, -0.05822623, 0.063807, 0.063513555, -0.016254058, -0.05633996, 0.010747168, -0.055180643, -0.017933596, -0.004776757, -0.062884726, -0.0347523, -0.0009819095, 0.03760496, -0.0693013, 0.055223253, 0.05571835, -0.006566618, -0.024995768, -0.016127579, 0.0846103, 0.039566707, -0.03304292, -0.024334863, 0.028909825, -0.007800859, 0.013188724, -0.066595145, 0.004573934, -0.052779682, -0.066076525, 0.010731272, -0.022984501, -0.052806195, 0.026902298, -0.013807457, 0.010474472, 0.00092899473, -0.0039380398, 0.02732027, -0.05474035, 0.06491937, 0.018167056, -0.019578358, -0.04402939, -0.09386426, 0.03700365, -0.024812624, 0.0023965372, 0.068112895, 0.0013545114, -0.018488958, 0.06604224, 0.022656584, 0.0029868088, 0.0010818389, 0.031246852, -0.05383678, 0.0033547257, 0.018464703, 0.010833801, -0.044284187, -0.056999933, -0.0010757803, 0.0034279027, 0.040241305, -0.056668207, -0.018543132, -0.08903751, 0.008962883, -0.0037839022, -0.019067602, 0.023671232, 0.046400174, 0.005217494, 0.055926412, 0.03562147, 0.06034174, -0.07390356, -0.03207419, 0.06346359, -0.009708822, 0.044872276, 0.05032992, -0.031254917, 0.020779952, -0.052435108, -0.01063663, -0.038744126, -0.0019619863, -0.047727782, -0.01387637, 0.01920304, 0.077976525, -0.054573614, -0.051430523, -0.0079415515, 0.09202196, -0.041945938, -0.07108463, -0.016847225, -0.006960493, -0.03381631, 0.048368666, -0.027409634, -0.042320203, 0.009589266, 0.023137778, -0.007905379, -0.0023211383, 0.041873515, 0.095347464, -0.07153123, -0.042168748, -0.08479435, -0.017006544, -0.004092579, -0.052806195, -0.07940039, -0.021862363, -0.00603431, -0.027660102, 0.0012343314, 0.045116212, -0.058984097, 0.060976453, 0.003202459, -0.017358372, 0.023796171, 0.027088037, -0.043060593, -0.055753313, -0.037612785, 0.025556568, 0.06276357, -0.014959082, -0.013444731, 0.020507108, -0.016732523, 0.046317946, -0.016010134, 0.016250657, 0.04041645, -0.07122725, 0.05731694, 0.07910689, -0.04521064, 0.011610118, 0.063682, -0.0016499176, -0.017406201, 0.002504159, -0.02841744, -8.188001e-05, 0.02809672, 0.02696574, 0.0368419, -0.07630421, 0.083394244, -0.048360493, 0.013417932, 0.035110787, 0.048312504, 0.032603238, 0.090178646, 0.022687737, 0.006868845, 0.028530505, 0.045185186, -0.04097323, 0.0028175868, 0.038101703, -0.093951866, 0.012886679, -0.07184525, -0.04355043, 0.006070501, -0.04605043, 0.0524447, 0.0503118, -0.083648205, -0.027314154, -0.033932865, -0.052154433, 0.044291526, -0.0411403, -0.04737155, -0.0488389, 0.013337547, -0.046102658, -0.0017678727, 0.08722986, -0.008186109, 0.015675927, 0.002789462, -0.046336427, 0.019483257, 0.01080171, 0.0060404236, -0.046920612, -0.05383381, 0.055847958, 0.03094623, 0.012606932, 0.021510499, -0.01367098, -0.071608804, 0.02534947, 0.030790739, 0.025430573, -0.039282866, -0.021880686, 0.031530336, 0.0065751905, -0.059012562, 0.016174112, 0.014323975, -0.055600297, -0.06327686, 0.0007925155, -0.032572795, 0.046815068, 0.0074544973, -0.006159259, -0.035753127, 0.04886314, -0.026201429, -0.03329462, 0.030305969, 0.018883273, 0.012391104, 0.044296343, 0.056841135, -0.0030866284, 0.06859566, 0.012015028, -0.04119121, -0.0073311743, -0.05915835, -0.022735262, 0.018551007, 0.047561206, 0.0362322, -0.030866668, -0.051297154, -0.09098813, 0.063193135, 0.011565007, -0.02029601, 0.009933975, 0.06814062, 0.021256156, 0.012529084, 0.041671786, 0.05754457, -0.019483583, 0.03856121, 0.027668176, 0.013417682, -0.005698279, 0.05998479, -0.036589667, 0.017161896, 0.049318522, -0.014435195, 0.0682766, 0.03051922, 0.04900409, -0.013036385, -0.013257847, 0.090930894, -0.01634741, 0.022200469, -0.010057279, -0.01949769, -0.04299617, 0.07266851, -0.058394585, -0.008202581, 0.038348198, 0.03676043, 0.024157135, 0.07426187, -0.012720134, -0.034491252, 0.017282989, -0.013741618, -0.06945241, -0.02943958, -0.021070639, -0.009992861, -0.05413105, -0.02403541, 0.09308325, -0.08513353, -0.04646692, -0.07487156, 0.039458573, 0.080216296, -0.07294897, 0.022258257, -0.0050610323, 0.020030456, 0.013562845, -0.005611547, 0.012321011, 0.014173648, 0.052479394, 0.04136205, -0.05811708, -0.06504647, 0.03597435, 0.04730559, -0.06149814, 0.024427518, 0.006243618, -0.07039271, -0.026242381, 0.012933507, -0.016335579, -0.080049075, 0.017919084, -0.024951028, -0.058903873, -0.012195617, 0.037455518, 0.019783055, -0.019031242, 0.063155316, -0.0012699465, 0.038301814, 0.054130252, 0.082774855, 0.023825018, -0.013741311, -0.0925043, 0.056934517, 0.049054448, -0.084901094, -0.03265152, 0.03782472, -0.061364703, -0.047935493, 0.030144056, -0.026726248, 0.08513927, -0.07686461, -0.058028042, -0.070050314, 0.04860326, 0.0722455, -0.095259815, -0.022615287, -0.090340264, -0.022208918, -0.004001788, -0.04547892, 0.029675972, -0.000104330706, 0.0346399, 0.056362893, -0.035725076, 0.0364203]')
as distance
FROM document_embedding
ORDER BY distance limit 3
you can see from original post that there is a problem with ordering with regular query. Have you tried it with cte? Something like this:
WITH documents AS MATERIALIZED (select metadata,
(embedding <=> '[0.09586733, .....]')
as distance
FROM document_embedding
limit 300)
SELECT metadata, distance
FROM documents
ORDER BY distance DESC
LIMIT 3
But still, it's not good solution because cte will give you 300 documents and later you will sort it and select first 3. Depends on your data, 301st entry can be entry which you are trying to find. So in case you will not find other solution you should change 300
to some reasonable value based on your data and probably not MATERIALIZED
.
well, let's wait for a fix then
When I query for cosine distances to return the distance in a new column, I get back unordered results.
Here's a reproducible script for how I'm setting up my dataset: https://gist.github.com/rsomani95/dfc1006fb63fbf861bb389cae894b97f
And this is the erroneous query:
The returned results look like this:
As you can see, the
distance
is not in order.