Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Dliu/pg browser #2

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bc922a2
Changes for websockets and cursors
daniel-liu-bitio Feb 22, 2022
86558d2
Add pg browser
daniel-liu-bitio Feb 28, 2022
a8d4e8f
Clean up webpack config file
daniel-liu-bitio Feb 28, 2022
b22bd76
Merge branch 'master' into dliu/pg-browser
daniel-liu-bitio Feb 28, 2022
5346973
Fix yarn.lock
daniel-liu-bitio Feb 28, 2022
ab56adf
Modify pg tests
daniel-liu-bitio Mar 1, 2022
e0506b7
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 1, 2022
096c823
Comment clarifications
daniel-liu-bitio Mar 1, 2022
7fae74e
Remove yarn.loc
daniel-liu-bitio Mar 1, 2022
aa6fcf4
Fix pg test defaults and comment clarifications
daniel-liu-bitio Mar 1, 2022
e3adc69
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 2, 2022
db91f5b
Merge branch 'dliu/pg-browser' of https://github.com/daniel-liu-bitio…
daniel-liu-bitio Mar 2, 2022
70880de
Add comment to connection.end
daniel-liu-bitio Mar 2, 2022
7b6c17b
Add back original IP/hostname functionality
daniel-liu-bitio Mar 2, 2022
ff56d38
Add 130-tests.js back into test suite
daniel-liu-bitio Mar 2, 2022
42e05cc
Restore original integration/connection/test-helper
daniel-liu-bitio Mar 2, 2022
b58ec5c
Change some devDependencies back to dependencies
daniel-liu-bitio Mar 2, 2022
62dde3f
Remove status message logging
daniel-liu-bitio Mar 3, 2022
b55e00d
Fix stream placeholder logic
daniel-liu-bitio Mar 3, 2022
8462ab8
Send closing code + status on connection end
daniel-liu-bitio Mar 7, 2022
2f4a80d
Remove commented out original tests
daniel-liu-bitio Mar 9, 2022
f05b81c
Add simple performance test file
daniel-liu-bitio Mar 14, 2022
b7eae9d
Add cursor -> select example
daniel-liu-bitio Mar 14, 2022
d622ec7
Add yarn.lock
daniel-liu-bitio Mar 14, 2022
7b10504
Add messages.d.ts
daniel-liu-bitio Mar 14, 2022
e915f5d
recent
daniel-liu-bitio Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add cursor -> select example
  • Loading branch information
daniel-liu-bitio committed Mar 14, 2022
commit b7eae9d87675129117c6cc38ff3fa56aafa2399e
48 changes: 48 additions & 0 deletions packages/pg/performance-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Runs a select statement on 10000 rows, compare performance between node pg and pg-browser
var time_pg
var time_ws

// with pg-browser
var { Client, Pool } = require("./lib/index.js")
var start = new Date().getTime();

var client = new Client({
database: 'postgres',
user: 'bitdotio-2',
password: 'password',
port: '5901',
})

client.connect(() => {
client.query("SELECT * FROM generate_series(1,10000)", () => {
var elapsed = new Date().getTime() - start;
time_ws = elapsed
console.log("Ws time: %d", time_ws)
client.end(() => {
// with regular pg
var { Client, Pool } = require('pg')
var start = new Date().getTime();

client = new Client({
database: 'postgres',
user: 'bitdotio-2',
password: 'password',
port: '5433',
})

client.connect(() => {
client.query("SELECT * FROM generate_series(1,10000)", () => {
var elapsed = new Date().getTime() - start;
time_pg = elapsed
console.log("Vanilla pg time: %d", time_pg)
client.end()
})
})
})
})
})





26 changes: 26 additions & 0 deletions packages/pg/select-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { Client } = require('pg')
const Cursor = require('pg-cursor')

const client = new Client({
database: 'postgres',
user: 'bitdotio-2',
password: 'password',
port: '5433',
})

client.connect()

const cursor = client.query(new Cursor("SELECT * FROM generate_series(1,100)"))
// read partially from cursor
cursor.read(1, () => {
console.log("Cursor read")
// send query from client, which will not execute since there is a PortalSuspended
client.query("SELECT 1", () => {
console.log("SELECT 1")
cursor.read(100, () => {
console.log("Cursor read again")
})
})
// if calling client.connection.query() or cursor.connection.query()
// instead, the portal will receive a commandComplete and then close
})