From: | Steven Grimm <sgrimm(at)thesegovia(dot)com> |
---|---|
To: | rob stone <floriparob(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Inconsistent performance with LIKE and bind variable on long-lived connection |
Date: | 2017-06-11 05:10:44 |
Message-ID: | CAOFXwWXx0FHeYdKAK3GsMePmvPng4oQtQa-dJArM1+EQqHnCSQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The problem doesn't appear to be specific to the JDBC driver. Tried a quick
version of this in Python for grins with a database that was already
populated by the Java code (sadly, the psycopg2 library doesn't directly
support prepared statements):
import psycopg2
import time
conn = psycopg2.connect('dbname=test')
cur = conn.cursor()
cur.execute('PREPARE myplan AS '
'SELECT col2 FROM test WHERE col1 = $1 AND col2 LIKE $2 ORDER
BY col2')
times = []
for i in range(0, 20):
start_time = time.time()
cur.execute('EXECUTE myplan (%s, %s)', ('xyz', '%'))
cur.fetchall()
end_time = time.time()
times.append(int((end_time - start_time) * 1000))
print(times)
The output looks similar to the pattern in the Java test code, though it
gets slow after 5 iterations rather than 9:
[7, 6, 6, 5, 6, 102, 104, 111, 107, 109, 108, 114, 102, 107, 107, 134, 102,
106, 108, 103]
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-06-11 06:10:19 | Re: Inconsistent performance with LIKE and bind variable on long-lived connection |
Previous Message | Alvaro Herrera | 2017-06-11 03:38:40 | Re: ERROR: unexpected chunk number 0 (expected 1) for toast value 76753264 in pg_toast_10920100 |