@@ -944,6 +944,7 @@ type BenchRowSimple struct {
944
944
BirthDate time.Time
945
945
Weight int32
946
946
Height int32
947
+ Tags []string
947
948
UpdateTime time.Time
948
949
}
949
950
@@ -957,13 +958,13 @@ func BenchmarkSelectRowsScanSimple(b *testing.B) {
957
958
b .Run (fmt .Sprintf ("%d rows" , rowCount ), func (b * testing.B ) {
958
959
br := & BenchRowSimple {}
959
960
for i := 0 ; i < b .N ; i ++ {
960
- rows , err := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
961
+ rows , err := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
961
962
if err != nil {
962
963
b .Fatal (err )
963
964
}
964
965
965
966
for rows .Next () {
966
- rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .UpdateTime )
967
+ rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .Tags , & br . UpdateTime )
967
968
}
968
969
969
970
if rows .Err () != nil {
@@ -982,6 +983,7 @@ type BenchRowStringBytes struct {
982
983
BirthDate time.Time
983
984
Weight int32
984
985
Height int32
986
+ Tags []string
985
987
UpdateTime time.Time
986
988
}
987
989
@@ -995,13 +997,13 @@ func BenchmarkSelectRowsScanStringBytes(b *testing.B) {
995
997
b .Run (fmt .Sprintf ("%d rows" , rowCount ), func (b * testing.B ) {
996
998
br := & BenchRowStringBytes {}
997
999
for i := 0 ; i < b .N ; i ++ {
998
- rows , err := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1000
+ rows , err := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
999
1001
if err != nil {
1000
1002
b .Fatal (err )
1001
1003
}
1002
1004
1003
1005
for rows .Next () {
1004
- rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .UpdateTime )
1006
+ rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .Tags , & br . UpdateTime )
1005
1007
}
1006
1008
1007
1009
if rows .Err () != nil {
@@ -1020,6 +1022,7 @@ type BenchRowDecoder struct {
1020
1022
BirthDate pgtype.Date
1021
1023
Weight pgtype.Int4
1022
1024
Height pgtype.Int4
1025
+ Tags pgtype.FlatArray [string ]
1023
1026
UpdateTime pgtype.Timestamptz
1024
1027
}
1025
1028
@@ -1045,7 +1048,7 @@ func BenchmarkSelectRowsScanDecoder(b *testing.B) {
1045
1048
for i := 0 ; i < b .N ; i ++ {
1046
1049
rows , err := conn .Query (
1047
1050
context .Background (),
1048
- "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" ,
1051
+ "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" ,
1049
1052
pgx.QueryResultFormats {format .code },
1050
1053
rowCount ,
1051
1054
)
@@ -1054,7 +1057,7 @@ func BenchmarkSelectRowsScanDecoder(b *testing.B) {
1054
1057
}
1055
1058
1056
1059
for rows .Next () {
1057
- rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .UpdateTime )
1060
+ rows .Scan (& br .ID , & br .FirstName , & br .LastName , & br .Sex , & br .BirthDate , & br .Weight , & br .Height , & br .Tags , & br . UpdateTime )
1058
1061
}
1059
1062
1060
1063
if rows .Err () != nil {
@@ -1076,7 +1079,7 @@ func BenchmarkSelectRowsPgConnExecText(b *testing.B) {
1076
1079
for _ , rowCount := range rowCounts {
1077
1080
b .Run (fmt .Sprintf ("%d rows" , rowCount ), func (b * testing.B ) {
1078
1081
for i := 0 ; i < b .N ; i ++ {
1079
- mrr := conn .PgConn ().Exec (context .Background (), fmt .Sprintf ("select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + %d) n" , rowCount ))
1082
+ mrr := conn .PgConn ().Exec (context .Background (), fmt .Sprintf ("select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + %d) n" , rowCount ))
1080
1083
for mrr .NextResult () {
1081
1084
rr := mrr .ResultReader ()
1082
1085
for rr .NextRow () {
@@ -1113,11 +1116,11 @@ func BenchmarkSelectRowsPgConnExecParams(b *testing.B) {
1113
1116
for i := 0 ; i < b .N ; i ++ {
1114
1117
rr := conn .PgConn ().ExecParams (
1115
1118
context .Background (),
1116
- "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" ,
1119
+ "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" ,
1117
1120
[][]byte {[]byte (strconv .FormatInt (rowCount , 10 ))},
1118
1121
nil ,
1119
1122
nil ,
1120
- []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code },
1123
+ []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code , format . code },
1121
1124
)
1122
1125
for rr .NextRow () {
1123
1126
rr .Values ()
@@ -1143,7 +1146,7 @@ func BenchmarkSelectRowsSimpleCollectRowsRowToStructByPos(b *testing.B) {
1143
1146
for _ , rowCount := range rowCounts {
1144
1147
b .Run (fmt .Sprintf ("%d rows" , rowCount ), func (b * testing.B ) {
1145
1148
for i := 0 ; i < b .N ; i ++ {
1146
- rows , _ := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1149
+ rows , _ := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1147
1150
benchRows , err := pgx .CollectRows (rows , pgx .RowToStructByPos [BenchRowSimple ])
1148
1151
if err != nil {
1149
1152
b .Fatal (err )
@@ -1167,7 +1170,7 @@ func BenchmarkSelectRowsSimpleAppendRowsRowToStructByPos(b *testing.B) {
1167
1170
benchRows := make ([]BenchRowSimple , 0 , rowCount )
1168
1171
for i := 0 ; i < b .N ; i ++ {
1169
1172
benchRows = benchRows [:0 ]
1170
- rows , _ := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1173
+ rows , _ := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1171
1174
var err error
1172
1175
benchRows , err = pgx .AppendRows (benchRows , rows , pgx .RowToStructByPos [BenchRowSimple ])
1173
1176
if err != nil {
@@ -1190,7 +1193,7 @@ func BenchmarkSelectRowsSimpleCollectRowsRowToStructByName(b *testing.B) {
1190
1193
for _ , rowCount := range rowCounts {
1191
1194
b .Run (fmt .Sprintf ("%d rows" , rowCount ), func (b * testing.B ) {
1192
1195
for i := 0 ; i < b .N ; i ++ {
1193
- rows , _ := conn .Query (context .Background (), "select n as id, 'Adam' as first_name, 'Smith ' || n as last_name, 'male' as sex, '1952-06-16'::date as birth_date, 258 as weight, 72 as height, '2001-01-28 01:02:03-05'::timestamptz as update_time from generate_series(100001, 100000 + $1) n" , rowCount )
1196
+ rows , _ := conn .Query (context .Background (), "select n as id, 'Adam' as first_name, 'Smith ' || n as last_name, 'male' as sex, '1952-06-16'::date as birth_date, 258 as weight, 72 as height, '{foo,bar,baz}'::text[] as tags, ' 2001-01-28 01:02:03-05'::timestamptz as update_time from generate_series(100001, 100000 + $1) n" , rowCount )
1194
1197
benchRows , err := pgx .CollectRows (rows , pgx .RowToStructByName [BenchRowSimple ])
1195
1198
if err != nil {
1196
1199
b .Fatal (err )
@@ -1214,7 +1217,7 @@ func BenchmarkSelectRowsSimpleAppendRowsRowToStructByName(b *testing.B) {
1214
1217
benchRows := make ([]BenchRowSimple , 0 , rowCount )
1215
1218
for i := 0 ; i < b .N ; i ++ {
1216
1219
benchRows = benchRows [:0 ]
1217
- rows , _ := conn .Query (context .Background (), "select n as id , 'Adam' as first_name , 'Smith ' || n as last_name , 'male' as sex , '1952-06-16'::date as birth_date , 258 as weight , 72 as height, '2001-01-28 01:02:03-05'::timestamptz as update_time from generate_series(100001, 100000 + $1) n" , rowCount )
1220
+ rows , _ := conn .Query (context .Background (), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , rowCount )
1218
1221
var err error
1219
1222
benchRows , err = pgx .AppendRows (benchRows , rows , pgx .RowToStructByPos [BenchRowSimple ])
1220
1223
if err != nil {
@@ -1234,7 +1237,7 @@ func BenchmarkSelectRowsPgConnExecPrepared(b *testing.B) {
1234
1237
1235
1238
rowCounts := getSelectRowsCounts (b )
1236
1239
1237
- _ , err := conn .PgConn ().Prepare (context .Background (), "ps1" , "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , nil )
1240
+ _ , err := conn .PgConn ().Prepare (context .Background (), "ps1" , "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , nil )
1238
1241
if err != nil {
1239
1242
b .Fatal (err )
1240
1243
}
@@ -1256,7 +1259,7 @@ func BenchmarkSelectRowsPgConnExecPrepared(b *testing.B) {
1256
1259
"ps1" ,
1257
1260
[][]byte {[]byte (strconv .FormatInt (rowCount , 10 ))},
1258
1261
nil ,
1259
- []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code },
1262
+ []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code , format . code },
1260
1263
)
1261
1264
for rr .NextRow () {
1262
1265
rr .Values ()
@@ -1335,7 +1338,7 @@ func BenchmarkSelectRowsRawPrepared(b *testing.B) {
1335
1338
conn := mustConnectString (b , os .Getenv ("PGX_TEST_DATABASE" )).PgConn ()
1336
1339
defer conn .Close (context .Background ())
1337
1340
1338
- _ , err := conn .Prepare (context .Background (), "ps1" , "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , nil )
1341
+ _ , err := conn .Prepare (context .Background (), "ps1" , "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], ' 2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + $1) n" , nil )
1339
1342
if err != nil {
1340
1343
b .Fatal (err )
1341
1344
}
@@ -1358,7 +1361,7 @@ func BenchmarkSelectRowsRawPrepared(b *testing.B) {
1358
1361
"ps1" ,
1359
1362
[][]byte {[]byte (strconv .FormatInt (rowCount , 10 ))},
1360
1363
nil ,
1361
- []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code },
1364
+ []int16 {format .code , pgx .TextFormatCode , pgx .TextFormatCode , pgx .TextFormatCode , format .code , format .code , format .code , format .code , format . code },
1362
1365
)
1363
1366
_ , err := rr .Close ()
1364
1367
require .NoError (b , err )
0 commit comments