VEC_DISTANCE() function that takes two binary strings (which are vectors of floats of the same length) and computes Euclidean distance between two multi-dimensional points, much like ST_DISTANCE() does.
it'll also work on the VECTOR(N) data type, when we'll have one
PlanetScale intends to support three or more different distance functions, so we need a syntax for that. Our proposal is VEC_L2Distance, VEC_IPDistance, and VEC_CosineDistance. This is similar to spatial types, which have separate functions for simple, Hausdorff, and Frechet distance.
We may in the future also want VEC_HammingDistance for one-bit vectors.
Patrick Reynolds
added a comment - PlanetScale intends to support three or more different distance functions, so we need a syntax for that. Our proposal is VEC_L2Distance, VEC_IPDistance, and VEC_CosineDistance. This is similar to spatial types, which have separate functions for simple, Hausdorff, and Frechet distance.
We may in the future also want VEC_HammingDistance for one-bit vectors.
No, not at all. If the distance is L2 (euclidean distance, |x - y|, then the result is a non-negative number, where 0 means a perfect match. That's how the euclidean distance is defined.
If the distance is cosine (1-cos(∠xy)), then it's 0 being a perfect match, 2 being the farthest possible. Again, that's just what a cosine distance is.
Sergei Golubchik
added a comment - - edited No, not at all. If the distance is L2 (euclidean distance, | x - y | , then the result is a non-negative number, where 0 means a perfect match. That's how the euclidean distance is defined.
If the distance is cosine ( 1-cos(∠ xy ) ), then it's 0 being a perfect match, 2 being the farthest possible. Again, that's just what a cosine distance is.
as we're modelling function names after GIS, we'll use ST_DISTANCE() and ST_DISTANCE_SPHERE() as role models. Meaning we'll have VEC_DISTANCE_EUCLIDEAN(), VEC_DISTANCE_COSINE(), etc.
May be VEC_DISTANCE() should mean Euclidean, but it'll likely be too confusing.
Sergei Golubchik
added a comment - as we're modelling function names after GIS, we'll use ST_DISTANCE() and ST_DISTANCE_SPHERE() as role models. Meaning we'll have VEC_DISTANCE_EUCLIDEAN() , VEC_DISTANCE_COSINE() , etc.
May be VEC_DISTANCE() should mean Euclidean, but it'll likely be too confusing.
People
Sergei Golubchik
Sergei Golubchik
Votes:
2Vote for this issue
Watchers:
19Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1223.2999997138977,"ttfb":419,"pageVisibility":"visible","entityId":126630,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a924b825-1218-4a7d-99bf-70187c459978","navigationType":0,"readyForUser":1293.2999997138977,"redirectCount":0,"resourceLoadedEnd":1771.3999996185303,"resourceLoadedStart":425.09999990463257,"resourceTiming":[{"duration":275.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":425.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":425.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":700.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":275.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":425.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":425.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":701.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":337.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":425.59999990463257,"connectEnd":425.59999990463257,"connectStart":425.59999990463257,"domainLookupEnd":425.59999990463257,"domainLookupStart":425.59999990463257,"fetchStart":425.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":425.59999990463257,"responseEnd":763.5,"responseStart":763.5,"secureConnectionStart":425.59999990463257},{"duration":424.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":425.8999996185303,"connectEnd":425.8999996185303,"connectStart":425.8999996185303,"domainLookupEnd":425.8999996185303,"domainLookupStart":425.8999996185303,"fetchStart":425.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":425.8999996185303,"responseEnd":850.6999998092651,"responseStart":850.6999998092651,"secureConnectionStart":425.8999996185303},{"duration":428.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":426,"connectEnd":426,"connectStart":426,"domainLookupEnd":426,"domainLookupStart":426,"fetchStart":426,"redirectEnd":0,"redirectStart":0,"requestStart":426,"responseEnd":854.6999998092651,"responseStart":854.6999998092651,"secureConnectionStart":426},{"duration":428.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":426.19999980926514,"connectEnd":426.19999980926514,"connectStart":426.19999980926514,"domainLookupEnd":426.19999980926514,"domainLookupStart":426.19999980926514,"fetchStart":426.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":426.19999980926514,"responseEnd":855.0999999046326,"responseStart":855.0999999046326,"secureConnectionStart":426.19999980926514},{"duration":429,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":426.5,"connectEnd":426.5,"connectStart":426.5,"domainLookupEnd":426.5,"domainLookupStart":426.5,"fetchStart":426.5,"redirectEnd":0,"redirectStart":0,"requestStart":426.5,"responseEnd":855.5,"responseStart":855.5,"secureConnectionStart":426.5},{"duration":481.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":426.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":426.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":908.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":429.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":426.7999997138977,"connectEnd":426.7999997138977,"connectStart":426.7999997138977,"domainLookupEnd":426.7999997138977,"domainLookupStart":426.7999997138977,"fetchStart":426.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":426.7999997138977,"responseEnd":855.8999996185303,"responseStart":855.8999996185303,"secureConnectionStart":426.7999997138977},{"duration":481.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":427,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":427,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":908.5,"responseStart":0,"secureConnectionStart":0},{"duration":429.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":427.19999980926514,"connectEnd":427.19999980926514,"connectStart":427.19999980926514,"domainLookupEnd":427.19999980926514,"domainLookupStart":427.19999980926514,"fetchStart":427.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":427.19999980926514,"responseEnd":856.5,"responseStart":856.5,"secureConnectionStart":427.19999980926514},{"duration":1125.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":428.5,"connectEnd":428.5,"connectStart":428.5,"domainLookupEnd":428.5,"domainLookupStart":428.5,"fetchStart":428.5,"redirectEnd":0,"redirectStart":0,"requestStart":428.5,"responseEnd":1554.3999996185303,"responseStart":1554.3999996185303,"secureConnectionStart":428.5},{"duration":1338.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":433,"connectEnd":433,"connectStart":433,"domainLookupEnd":433,"domainLookupStart":433,"fetchStart":433,"redirectEnd":0,"redirectStart":0,"requestStart":433,"responseEnd":1771.3999996185303,"responseStart":1771.3999996185303,"secureConnectionStart":433},{"duration":661.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":920,"connectEnd":920,"connectStart":920,"domainLookupEnd":920,"domainLookupStart":920,"fetchStart":920,"redirectEnd":0,"redirectStart":0,"requestStart":920,"responseEnd":1581.5,"responseStart":1581.5,"secureConnectionStart":920},{"duration":642.1999998092651,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1215.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1215.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1857.3999996185303,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":249,"responseStart":419,"responseEnd":425,"domLoading":422,"domInteractive":1808,"domContentLoadedEventStart":1808,"domContentLoadedEventEnd":1853,"domComplete":2191,"loadEventStart":2191,"loadEventEnd":2192,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1787.5},{"name":"bigPipe.sidebar-id.end","time":1788.3999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1788.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":1790.5},{"name":"activityTabFullyLoaded","time":1870.5999999046326}],"measures":[],"correlationId":"412494d9616d03","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":103,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
PlanetScale intends to support three or more different distance functions, so we need a syntax for that. Our proposal is VEC_L2Distance, VEC_IPDistance, and VEC_CosineDistance. This is similar to spatial types, which have separate functions for simple, Hausdorff, and Frechet distance.
We may in the future also want VEC_HammingDistance for one-bit vectors.