Skip to content

Commit c14764d

Browse files
committed
Add pg-promise-native
1 parent 95ef7fa commit c14764d

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ client | select | select_arg | select_args | select_where
2121
:--------- | -------------: | -------------: | -------------: | -------------:
2222
postgres | 82ms (5.1x) | 91ms (5.3x) | 226ms (3.6x) | 229ms (5.0x)
2323
pg-promise | 331ms (1.3x) | 368ms (1.3x) | 605ms (1.3x) | 771ms (1.5x)
24+
pg-promise-native | 0.317s (1.3x) | 0.401s (1.2x) | 0.618s (1.3x) | 0.799s (1.4x)
2425
pg | 292ms (1.4x) | 473ms (1.0x) | 772ms (1.1x) | 1070ms (1.1x)
2526
pg-native | 419ms (1.0x) | 478ms (1.0x) | 816ms (1.0x) | 1138ms (1.0x)
2627
slonik | 10466ms (0.0x) | 10904ms (0.0x) | 11190ms (0.0x) | 11107ms (0.0x)

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const queries = [
77
, clients = [
88
'postgres',
99
'pg-promise',
10+
'pg-promise-native',
11+
'postgres-promise',
1012
'pg',
1113
'pg-native',
1214
//'slonik'

pg-promise-native/index.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const pg = require('pg-promise')
2+
3+
const db = pg()({ max: 4, pgNative: true })
4+
5+
module.exports = {
6+
queries: {
7+
select: () => db.query('select 1 as x'),
8+
select_arg: () => db.query('select $1 as x', [1]),
9+
select_args: () => db.query(`select
10+
$1::int as int,
11+
$2 as string,
12+
$3::timestamp with time zone as timestamp,
13+
$4 as null,
14+
$5::bool as boolean,
15+
$6::bytea as bytea,
16+
$7::jsonb as json
17+
`, [
18+
1337,
19+
'wat',
20+
new Date().toISOString(),
21+
null,
22+
false,
23+
Buffer.from('awesome'),
24+
JSON.stringify([{ some: 'json' }, { array: 'object' }])
25+
]),
26+
select_where: () => db.query(`select * from pg_catalog.pg_type where typname = $1`, ['bool'])
27+
},
28+
end: () => db.$pool.end()
29+
}

results.png

111 KB
Loading

0 commit comments

Comments
 (0)