Skip to content

Instantly share code, notes, and snippets.

@renormalist
Created June 24, 2019 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renormalist/2074a397da997c4e0376417747f57ee1 to your computer and use it in GitHub Desktop.
Save renormalist/2074a397da997c4e0376417747f57ee1 to your computer and use it in GitHub Desktop.
Mojo::Pg - linear insert speed
#! /usr/bin/env perl
# Mojolicious 8.17
# PostgreSQL 9.5.14
use 5.022;
use Mojo::Pg;
use Benchmark ':all';
my $id;
my $pg = Mojo::Pg->new('postgresql://'.$ENV{USER}.'@/tapdomdb_test');
my $db = $pg->db;
timethis(10_000, sub {
$id = $db->insert('tap_dom',
{uuid => '5c437cb4-e326-4dde-960d-b575e78663b0'},
{returning => 'tap_dom_id'}
)->hash->{tap_dom_id};
});
say "Last inserted id: $id";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment