File tree 4 files changed +32
-0
lines changed
4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ client | select | select_arg | select_args | select_where
21
21
:--------- | -------------: | -------------: | -------------: | -------------:
22
22
postgres | 82ms (5.1x) | 91ms (5.3x) | 226ms (3.6x) | 229ms (5.0x)
23
23
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)
24
25
pg | 292ms (1.4x) | 473ms (1.0x) | 772ms (1.1x) | 1070ms (1.1x)
25
26
pg-native | 419ms (1.0x) | 478ms (1.0x) | 816ms (1.0x) | 1138ms (1.0x)
26
27
slonik | 10466ms (0.0x) | 10904ms (0.0x) | 11190ms (0.0x) | 11107ms (0.0x)
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const queries = [
7
7
, clients = [
8
8
'postgres' ,
9
9
'pg-promise' ,
10
+ 'pg-promise-native' ,
11
+ 'postgres-promise' ,
10
12
'pg' ,
11
13
'pg-native' ,
12
14
//'slonik'
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments