Suor/pg-bricks

Native bindings support

danistefanovic opened this issue · 5 comments

Would be nice, if the user could decide whether to use pg or pg-native:

  • native (C/C++) bindings for PostgreSQL increase the parsing speed by 20-30%
  • pg-native provides the same interface as pg
Suor commented

How do you propose making this to work? Always try pg-native first, then pg? Look for some env var? Change .configure() signature to accept some flag?

I would try something like this: Use pg-native if available, or else fall back to pg.

try {
    return require('pg').native;
} catch (e) {
    return require('pg');
}

What do you prefer?

Suor commented

Simple fallback doesn't work at this stage, see brianc/node-postgres#940, will wait for Brians response.

I've noticed pg and pg-native differ on a couple of things and aren't always kept in sync, so I'd prefer only using pg-native by explicit choice of the consumer

Suor commented

Supported through autouse now - 9205beb.

After some thought I think mirror API should be better:

var pg = require('pg-bricks').configure(...);
pg.native.select().from('some_table').run();
// or
var pg = require('pg-bricks').native.configure(...);