Skip to content

Instantly share code, notes, and snippets.

test
UPDATE inventory.vehicles AS v
SET date_sold = 'NOW'
WHERE v.date_sold IS NULL
AND EXISTS (
SELECT * FROM temp_vehicles AS t
WHERE v.lot_id = t.lot_id
)
AND NOT EXISTS (
SELECT * FROM temp_vehicles AS t
WHERE v.lot_id = t.lot_id AND v.vin = t.vin
If three runners join a race and the first two runners tie, is the third runner to cross the finish line in second place or in third? This is the difference between `rank()`, and `dense_rank()`. Both of these functions agree that the first and second runners are in a tie for first place, but `rank()` will assign the third runner to the third place. In this configuration you would say two runners tied for first place and the third runner came in third place. Conversely, dense_rank() will say the first two runners tied for first place, and the third runner came in second place. In SQL parlance, the `dense_rank()` has no *gaps* you can not skip a second place because two of the runners preceding it were tied. In comparison, `rank()` will have gaps anytime two consecutive rows preceding it tied by the **ORDER BY** clause.
dealermade=# EXPLAIN ANALYZE select * from inventory.vehicles where vin = coalesce ( '1FTYR10C6YPB35818', vin );
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on vehicles (cost=4.29..12.18 rows=2 width=834) (actual time=0.035..0.037 rows=1 loops=1)
Recheck Cond: ((vin)::text = '1FTYR10C6YPB35818'::text)
-> Bitmap Index Scan on vehicles__vin_textpatternops (cost=0.00..4.29 rows=2 width=0) (actual time=0.024..0.024 rows=1 loops=1)
Index Cond: ((vin)::text = '1FTYR10C6YPB35818'::text)
Total runtime: 0.155 ms
(5 rows)
10:46 -!- Irssi: Join to #postgresql was synced in 1 secs
10:46 < EvanCarroll> if you do UPDATE foo SET bar = bar+1, on a table with a trillion rows, will you be able to insert into that table before that update txn completes?
10:46 < RhodiumToad> yes
10:46 < orion> RhodiumToad: I guess it might make sense to create a rule to prevent updates to the table... to force the application to delete and insert a new event using the inserter function.
10:46 < EvanCarroll> does an update on a large table, lock the table? or all rows in it?
10:46 < RhodiumToad> orion: trigger, not rule
10:47 < RhodiumToad> EvanCarroll: each updated row individually
10:47 < EvanCarroll> and if so, is there an overhead on locking all of the rows in a very large table -- and can you get around that overhead by locking the /whole/ table
10:47 < RhodiumToad> EvanCarroll: and no, there's no overhead, because the simple fact that the old row version now has xmax set is what makes it "locked"
10:47 < johto> as long as there are no BEFORE trigge
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
my $copy = do {
use Regexp::Grammars;
qr{
<ACTION=(\\COPY)> <from>
package MyClass;
use Moose;
use MyTypes qw( MyDate );
use namespace::clean -except => 'meta';
has bday => (isa => MyDate, is => 'ro', coerce => 1);
__PACKAGE__->meta->make_immutable;
1;
16:18 -!- Irssi: #catalyst: Total of 271 nicks [39 ops, 0 halfops, 4 voices, 228 normal]
16:18 -!- Channel #catalyst created Thu Mar 10 12:31:50 2005
16:18 -!- Irssi: Join to #catalyst was synced in 1 secs
16:19 < EvanCarroll> I ported the test suite for Catalyst::Plugin::Params::Nested to use Catalyst::Test from
Test::MockObject (which is removed from Catalyst proper, and doesn't currently build properly)
16:19 < EvanCarroll> However, I'm having one problem wit Catalyst::Test remaining: [error] No default action defined
16:19 < EvanCarroll> anyone know how to kill that silly warning
16:19 < EvanCarroll> I've ensured the namespace in my root controller is ''
16:20 < EvanCarroll> still no joy.
16:23 <@dhoss> anyone seen this? Use of uninitialized value $storedpassword in string eq at
@EvanCarroll
EvanCarroll / constructor_provided_and_strict_default.pm
Created October 25, 2010 20:18
This file demonstrates the counter-intuitive behavior of Moose in regards to strict-defaults, and constructor provided arguments.
package Class;
use Moose;
has "foo" => (
isa => 'Str'
, is => 'ro'
, predicate => '_has_foo'
);
has "bar" => (
is => 'ro'
< volume: -9
< backlight timeout: 4
< backlight timeout plugged: 5
< selector type: bar (inverse)
< brightness: 1
< foreground color: 000000
< background color: FFFFFF
< party mode: on
< volume fade: off
< scan min step: 30