ankane / pgslice

Postgres partitioning as easy as pie
MIT License
1.11k stars 67 forks source link

No support for UUID primary keys #17

Closed ukd1 closed 6 years ago

ukd1 commented 6 years ago
bundle exec pgslice fill events --batch-size 1000
bundler: failed to load command: pgslice (/Users/russ/.rbenv/versions/2.5.0/bin/pgslice)
PG::UndefinedFunction: ERROR:  function max(uuid) does not exist
LINE 1: SELECT MAX("id") FROM "public"."events"
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/lib/pgslice.rb:481:in `exec_params'
  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/lib/pgslice.rb:481:in `execute'
  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/lib/pgslice.rb:568:in `max_id'
  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/lib/pgslice.rb:296:in `fill'
  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/lib/pgslice.rb:33:in `perform'
  /Users/russ/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pgslice-0.4.1/exe/pgslice:5:in `<top (required)>'
  /Users/russ/.rbenv/versions/2.5.0/bin/pgslice:23:in `load'
  /Users/russ/.rbenv/versions/2.5.0/bin/pgslice:23:in `<top (required)>'
ankane commented 6 years ago

Hey @ukd1, as far as I know, there's not a great way to backfill UUIDs while inserts are happening since UUIDs aren't guaranteed to be inserted in order (even time-based UUIDs won't necessarily be in order if they are generated on multiple machines). I'm happy to accept a PR if there's a reliable way to do it with little additional complexity.

ukd1 commented 6 years ago

@ankane I just ended up inserting all the rows back in to the partitioned table in one go, which was slow, but fine for our us. I've no time to fix this I'm afraid.

ankane commented 6 years ago

No worries.