fix: major performance issues with bytea performance #2240

This commit is contained in:
regevbr 2020-07-03 17:56:13 +03:00
parent 410a6ab248
commit 69af2672ed
No known key found for this signature in database
GPG Key ID: 47F0B00C687E259E

View File

@ -1,5 +1,4 @@
const pg = require('./lib')
const pool = new pg.Pool()
const params = {
text:
@ -17,7 +16,7 @@ const seq = {
}
const exec = async (client, q) => {
const result = await client.query({
await client.query({
text: q.text,
values: q.values,
rowMode: 'array',
@ -39,7 +38,9 @@ const bench = async (client, q, time) => {
const run = async () => {
const client = new pg.Client()
await client.connect()
console.log('start')
await client.query('CREATE TEMP TABLE foobar(name TEXT, age NUMERIC)')
await client.query('CREATE TEMP TABLE buf(name TEXT, data BYTEA)')
await bench(client, params, 1000)
console.log('warmup done')
const seconds = 5
@ -61,7 +62,21 @@ const run = async () => {
console.log('insert queries:', queries)
console.log('qps', queries / seconds)
console.log('on my laptop best so far seen 5799 qps')
console.log()
console.log('')
console.log('Warming up bytea test')
await client.query({
text: 'INSERT INTO buf(name, data) VALUES ($1, $2)',
values: ['test', Buffer.allocUnsafe(104857600)],
})
console.log('bytea warmup done')
const start = Date.now()
const results = await client.query('SELECT * FROM buf')
const time = Date.now() - start
console.log('bytea time:', time, 'ms')
console.log('bytea length:', results.rows[0].data.byteLength, 'bytes')
console.log('on my laptop best so far seen 1107ms and 104857600 bytes')
await client.end()
await client.end()
}