compile cube extension with float4 precision storing

Started by Siarhei Dover 5 years ago2 messages
#1Siarhei D
siarhei.damanau@gmail.com

Is it possible to make cube extension with float(4bytes) precision instead
of double(8bytes)?

I use cube extension for storing embedding vectors and calculation distance
on them. During comparing vectors, a 4byte float precision is enough.
Storing 8 byte double precision is wasting disk space.

Now to avoid disk wasting I store vectors as real[] array and create cube
objects on the fly. But this solution is wasting cpu time

--

Siarhei Damanau

#2Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Siarhei D (#1)
Re: compile cube extension with float4 precision storing

On Fri, Jun 12, 2020 at 02:41:08PM +0300, Siarhei D wrote:

Is it possible to make cube extension with float(4bytes) precision instead
of double(8bytes)?

I use cube extension for storing embedding vectors and calculation distance
on them. During comparing vectors, a 4byte float precision is enough.
Storing 8 byte double precision is wasting disk space.

Now to avoid disk wasting I store vectors as real[] array and create cube
objects on the fly. But this solution is wasting cpu time

I don't think there's a built-in support for that, so the only option I
can think of is creating your own cube "copy" extension using float4.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services