Skip to content

Commit 72cadf2

Browse files
authored
try "requests" lib with plpython2u
1 parent 5bc416b commit 72cadf2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

benchmarks.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ create or replace function get(uri character varying) returns text as $$
2828
return data.read()
2929
$$
3030
language plpython2u volatile;
31+
create or replace function get_requests(uri character varying) returns text as $$
32+
import requests
33+
r = requests.get(uri)
34+
return r.text
35+
$$ language plpython2u volatile;
3136
3237
-- plpython3u
3338
create extension plpython3u; -- do beforehand: sudo apt-get install postgresql-plpython3-9.6
@@ -52,6 +57,7 @@ postgres@dev:~$ #### http, localhost
5257
postgres@dev:~$ echo "select left(http_get.content, 50) from http_get('http://localhost/robots.txt');" > ~/local_http_c.sql
5358
postgres@dev:~$ echo "select left(_get, 50) from http_client._get('http://localhost/robots.txt', 2);" > ~/local_http_plsh.sql
5459
postgres@dev:~$ echo "select left(get, 50) from get('http://localhost/robots.txt');" > ~/local_http_python.sql
60+
postgres@dev:~$ echo "select left(get_requests, 50) from get_requests('http://localhost/robots.txt');" > ~/local_http_python_requests.sql
5561
postgres@dev:~$ echo "select left(get_python3, 50) from get_python3('http://localhost/robots.txt');" > ~/local_http_python3.sql
5662
postgres@dev:~$ pgbench -f ~/local_http_c.sql -c 10 -t 100 test
5763
starting vacuum...end.
@@ -89,6 +95,18 @@ number of transactions actually processed: 1000/1000
8995
latency average = 2.203 ms
9096
tps = 4539.882871 (including connections establishing)
9197
tps = 4602.161543 (excluding connections establishing)
98+
postgres@dev:~$ pgbench -f ~/local_http_python_requests.sql -c 10 -t 100 test
99+
starting vacuum...end.
100+
transaction type: /var/lib/postgresql/local_http_python_requests.sql
101+
scaling factor: 1
102+
query mode: simple
103+
number of clients: 10
104+
number of threads: 1
105+
number of transactions per client: 100
106+
number of transactions actually processed: 1000/1000
107+
latency average = 16.941 ms
108+
tps = 590.275913 (including connections establishing)
109+
tps = 591.321016 (excluding connections establishing)
92110
postgres@dev:~$ pgbench -f ~/local_http_python3.sql -c 10 -t 100 test
93111
starting vacuum...end.
94112
transaction type: /var/lib/postgresql/local_http_python3.sql
@@ -292,6 +310,7 @@ Method | Latency, ms | TPS
292310
pgsql-http (C) | 5.01 | 2007
293311
plsh (curl) | 19.20 | 521.6
294312
plpython2u | 2.20 | 4602
313+
plpython2u-requests | 16.94 | 591.3
295314
plpython3u | 3.18 | 3175
296315

297316
### Results for HTTP, ya.ru:

0 commit comments

Comments
 (0)