Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does operator <=> do in PostgreSQL

I found such query in some of the working repository:

SELECT id, full_name_tsvector <=> plainto_tsquery('English', 'test') AS rank
FROM names_tsvectors 
WHERE "full_name_tsvector" @@ plainto_tsquery('English', 'test')
ORDER BY rank LIMIT 1000

The query gives result:

id   |rank     |
-----+---------+
 6574|13.159472|
25653|13.159472|
 5730|13.159472|
21924|13.159472|
 6578|13.159472|
 5813|13.159472|
22188| 16.44934|
21959| 16.44934|
20360| 16.44934|

So my question is – what does operator <=> do actually? I haven’t found anything about that operator except that it does not exist in Postgres.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

PostgreSQL doesn’t contain an operator with that name. You probably got it from an extension.

Figure out which extension that is using the query

SELECT oprname AS operator_name,
       oprnamespace::regnamespace AS operator_schema,
       e.extname AS extension_name
FROM pg_operator AS o
   JOIN pg_depend AS d
      ON d.classid = 'pg_operator'::regclass
         AND d.objid = o.oid
   JOIN pg_extension AS e
      ON d.refclassid = 'pg_extension'::regclass
         AND d.refobjid = e.oid
WHERE d.deptype = 'e'
  AND o.oprname = '<=>';

and look at the documentation of that software.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading