Coder Social home page Coder Social logo

Comments (4)

paddycarver avatar paddycarver commented on June 14, 2024

My solution to this so far is to use two functions to hex encode the data in a varchar prior to inserting it and decode it when retrieving it. Which really rather defeats the purpose of packing the information in a uint64 in the first place, doesn't it? Any better solution I'm missing?

from pq.

fdr avatar fdr commented on June 14, 2024

Unfortunately uint64s are not supported by Postgres. Actually, no unsigned quantities are, unless you count the system type oid which is a uint32 if memory serves...I don't recommend relying on that, though. You can use a numeric, but that'll be slower. Another option is bytea, but I think the underlying varlena will introduce a lot of overhead also.

The nuclear option is to write an extension that supports unsigned integers for Postgres in C, and install it...then perhaps teach pq to understand how to deal with encodings for user defined types, which has issues similar to #49. I'm surprised such a 'unsigned integer extension' doesn't show up quickly via web search. Someone last had a go in 2008 it seems.

A workaround would be to use the 'uuid' type, which is double-wide at 128, but you can choose to just use the low bits or something. In spite of their rendition on the wire, they are stored as fixed-precision 128-bit quantities. This is still slower than a real 64-bit integer, but faster than numeric in all likelihood.

from pq.

fdr avatar fdr commented on June 14, 2024

(Seeing as how this is not a pq-solvable issue, putting aside user-defined-data-types and encodings, closing)

from pq.

paddycarver avatar paddycarver commented on June 14, 2024

Awesome, thanks for the ideas. Appreciate it.

from pq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.