Re: Filtering by UUID

From: Colin Morelli <colin(dot)morelli(at)gmail(dot)com>
To: Guyren Howe <guyren(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Filtering by UUID
Date: 2016-09-29 23:14:55
Message-ID: CAPtU-UqhejAEzzy4bKFRn=1hDwV0EuMWxR6kepEtf8Uj+CV6CA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well then...just like that you made me feel like a total idiot! Hah.

I guess that would work fine. I just need to encode some additional
information in the pagination links that the API returns (a pagination
"marker" would be a combination of created_at and uuid).

I know this question is virtually impossible to answer without more
information, but based on your gut - do you think it would make sense to
define a compound index across (created_at, uuid), or do you think just an
index on created_at is enough, if we can assume that *most* records (>80%)
won't have collisions on their created_at timestamp?

Thanks!
Colin

On Thu, Sep 29, 2016 at 7:09 PM Guyren Howe <guyren(at)gmail(dot)com> wrote:

> On Sep 29, 2016, at 16:03 , Colin Morelli <colin(dot)morelli(at)gmail(dot)com> wrote:
> >
> > Hey list,
> >
> > I'm using UUID primary keys in my application. I need to add pagination,
> and am trying to avoid OFFSET/LIMIT. I do have a created_at timestamp that
> I could use, but it's possible for multiple records to be created at the
> same timestamp (postgres offers millisecond precision here, I believe?)
> >
> > Is there an efficient way to filter based on the time component of UUID
> v1s? WHERE id > 'some-uuid' doesn't seem to work, as it looks like it's
> just performing a lexicographic sort on the hex representation of the UUID.
> Or, alternatively, does anyone have other suggestions on paginating large
> data sets?
>
> Why not just sort on (created_at, uuid) (ie us the UUID just to force a
> complete ordering)?
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guyren Howe 2016-09-29 23:18:09 Re: Filtering by UUID
Previous Message Guyren Howe 2016-09-29 23:08:47 Re: Filtering by UUID