Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id B64C81297414 for ; Tue, 17 Jul 2012 11:46:50 -0300 (ADT) Received: from avellino.dedalus.eu ([217.174.120.25] helo=mail.dedalus.eu) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sr92z-0007kc-43 for pgsql-odbc@postgresql.org; Tue, 17 Jul 2012 14:46:49 +0000 Received: from mail.dedalus.eu (avellino.dedalus.eu [10.11.51.25]) by mail.dedalus.eu (Postfix) with ESMTPA id 9C268200006 for ; Tue, 17 Jul 2012 16:46:31 +0200 (CEST) Received: from [10.5.7.23] ([10.11.51.25] helo=[10.5.7.23]) with IPv4:25 by mail.dedalus.eu; 17 Jul 2012 16:46:31 +0200 Message-ID: <50057AC6.8030904@dedalus.eu> Date: Tue, 17 Jul 2012 16:46:30 +0200 From: Andrea Ricci Reply-To: andrea.ricci@dedalus.eu Organization: Dedalus SpA User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: ByteA column retrieved in 31 minutes ... Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.2 (-) X-Archive-Number: 201207/10 X-Sequence-Number: 10904 Hi,
I'm using a 9.0.2 db in a PowerBuilder 12.1 application, connecting to it via ODBC driver 09.00.0200.

I have a table with a bytea column:

CREATE TABLE docs
(
=C2=A0 blobid character(7) NOT NULL,
=C2=A0 descript character varying(40),
=C2=A0 data date,
=C2=A0 "lock" character(1),
=C2=A0 ora character(5),
=C2=A0 parita character(1),
=C2=A0 tipo character(3),
=C2=A0 dbvtesto bytea,
=C2=A0 CONSTRAINT docs_pkey PRIMARY KEY (blobid),
=C2=A0 CONSTRAINT fk1_docs FOREIGN KEY (blobid)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 REFERENCES blob (blobid) MATCH SIMPL= E
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ON UPDATE NO ACTION ON DELETE CASCAD= E
)
WITH (
=C2=A0 OIDS=3DFALSE
);



When I retrieve via embedded SQL the dbvtesto column (using PK obv.) I get it in few seconds if its length is about 10 KB, but I've to wait 31 minutes (!) if it's about 1 MB.

If someone has a proposal ...

The logs:
psqlodbclog:

[70.282]conn=3D0F0EB070, query=3D'select dbvtesto=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 FROM docs WHERE blobid =3D'000005T' '
[84.635]=C2=A0=C2=A0=C2=A0 [ fetched 1 rows ]
[84.657]conn=3D0F0EB070, query=3D'select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when 'd' then t.typbasetype else 0 end, t.typtypmod from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid =3D c.relnamespace and c.oid =3D 252865) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid =3D c.oid) inner join pg_catalog.pg_type t on t.oid =3D a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid =3D a.attrelid and d.adnum = =3D a.attnum order by n.nspname, c.relname, attnum'
[84.694]=C2=A0=C2=A0=C2=A0 [ fetched 8 rows ]
[84.745]PGAPI_Columns: table=3D'docs',field_name=3D'blobid',type=3D1042,name=3D'bpchar'
[84.773]PGAPI_Columns: table=3D'docs',field_name=3D'descript',type=3D1043,name=3D'varchar' [84.803]PGAPI_Columns: table=3D'docs',field_name=3D'data',type=3D1082,name=3D'date'
[84.829]PGAPI_Columns: table=3D'docs',field_name=3D'lock',type=3D1042,name=3D'bpchar'
[84.858]PGAPI_Columns: table=3D'docs',field_name=3D'ora',type=3D1042,name=3D'bpchar'
[84.888]PGAPI_Columns: table=3D'docs',field_name=3D'parita',type=3D1042,name=3D'bpchar'
[84.916]PGAPI_Columns: table=3D'docs',field_name=3D'tipo',type=3D1042,name=3D'bpchar'
[84.945]PGAPI_Columns: table=3D'docs',field_name=3D'dbvtesto',type=3D17,name=3D'bytea'
[1886.060]conn=3D0F0EB070, query=3D'select dbvcargo=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 FROM blob WHERE blobid =3D'000005T' '

mylog:
[14596-70.280]CC_send_query: conn=3D0F0EB070, query=3D'select dbvtesto=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FROM docs WHERE= blobid =3D'000005T' '
[14596-70.283]send_query: done sending query 76bytes flushed
[14596-70.284]in QR_Constructor
[14596-70.285]exit QR_Constructor
[14596-70.285]read -1, global_socket_buffersize=3D4096
[14596-70.286]Lasterror=3D10035
[14596-70.330]read 4096, global_socket_buffersize=3D4096
[14596-70.331]send_query: got id =3D 'T'
[14596-70.331]QR_fetch_tuples: cursor =3D '', self->cursor=3D00000= 000
[14596-70.332]num_fields =3D 1
[14596-70.333]READING ATTTYPMOD
[14596-70.333]CI_read_fields: fieldname=3D'dbvtesto', adtid=3D17, adtsize=3D-1, atttypmod=3D-1 (rel,att)=3D(252865,8)
[14596-70.335]QR_fetch_tuples: past CI_read_fields: num_fields =3D 1<= br> [14596-70.336]MALLOC: tuple_size =3D 100, size =3D 800
[14596-70.336]QR_next_tuple: inTuples =3D true, falling through: fcount =3D 0, fetch_number =3D 0
[14596-70.338]read 4096, global_socket_buffersize=3D4096

766 similar rows + last at 2315

[14596-70.594]read 2315, global_socket_buffersize=3D4096
[14596-70.594]qresult: len=3D3139786, buffer=3D' ....

the text ...

[14596-84.635]end of tuple list -- setting inUse to false: this =3D 0F0EE560 SELECT 1
[14596-84.636]_QR_next_tuple: 'C' fetch_total =3D 1 & this_fetch = =3D 1
[14596-84.636]QR_next_tuple: backend_rows < CACHE_SIZE: brows =3D 0, cache_size =3D 0
[14596-84.636]QR_next_tuple: reached eof now
[14596-84.637]send_query: got id =3D 'Z'
[14596-84.637]=C2=A0=C2=A0=C2=A0=C2=A0 done sending the query:
[14596-84.637]extend_column_bindings: entering ... self=3D0F0EE7C0, bindings_allocated=3D0, num_columns=3D1
[14596-84.637]exit extend_column_bindings=3D1110E070

many similar rows, the blocks are repeated on 40000 bytes step
n.b.: 40000 is the value of MaxVarchar in ODBC configuration and ByteaAsLo =3D 0 (but set it to 1 doesn't change the behaviour)

[14596-801.327]SQL_C_BINARY: len =3D 929892, copy_len =3D 40000
[14596-801.327]STATEMENT WARNING: func=3DPGAPI_GetData, desc=3D'', errnum=3D-2, errmsg=3D'The buffer was too small for the GetData.'
[14596-801.328][SQLGetData][14596-801.328]PGAPI_GetData: enter, stmt=3D0F0EE738 icol=3D1
[14596-801.329]=C2=A0=C2=A0=C2=A0=C2=A0 num_rows =3D 1
[14596-801.329]=C2=A0=C2=A0=C2=A0=C2=A0 value =3D '


[14596-815.310]**** PGAPI_GetData: icol =3D 0, target_type =3D -2, field_type =3D 17, value =3D '

[14596-829.403]copy_and_convert: field_type =3D 17, fctype =3D -2, va= lue =3D '....

[14596-843.453]SQL_C_BINARY: len =3D 889892, copy_len =3D 40000
[14596-843.453]STATEMENT WARNING: func=3DPGAPI_GetData, desc=3D'', errnum=3D-2, errmsg=3D'The buffer was too small for the GetData.'
[14596-843.454][SQLGetData][14596-843.454]PGAPI_GetData: enter, stmt=3D0F0EE738 icol=3D1
[14596-843.454]=C2=A0=C2=A0=C2=A0=C2=A0 num_rows =3D 1
[14596-843.454]=C2=A0=C2=A0=C2=A0=C2=A0 value =3D '...


The ODBC configuration:
"Driver"=3D"C:\\Programmi\\PostgreSQL\\9.0\\PSQLODBC35W.DLL"
"CommLog"=3D"1"
"Debug"=3D"0"
"Fetch"=3D"100"
"Optimizer"=3D"0"
"Ksqo"=3D"0"
"UniqueIndex"=3D"1"
"UseDeclareFetch"=3D"0"
"UnknownSizes"=3D"0"
"TextAsLongVarchar"=3D"1"
"UnknownsAsLongVarchar"=3D"0"
"BoolsAsChar"=3D"1"
"Parse"=3D"0"
"CancelAsFreeStmt"=3D"0"
"MaxVarcharSize"=3D"40000"
"MaxLongVarcharSize"=3D"80000"
"ExtraSysTablePrefixes"=3D"dd_;"
"Description"=3D""
"Database"=3D"Argos_UTF"
"Servername"=3D"localhost"
"Port"=3D"5432"
"Username"=3D"postgres"
"UID"=3D"postgres"
"Password"=3D"postgres"
"ReadOnly"=3D"0"
"ShowOidColumn"=3D"0"
"FakeOidIndex"=3D"0"
"RowVersioning"=3D"0"
"ShowSystemTables"=3D"0"
"Protocol"=3D"7.4-1"
"ConnSettings"=3D""
"DisallowPremature"=3D"0"
"UpdatableCursors"=3D"1"
"LFConversion"=3D"1"
"TrueIsMinus1"=3D"0"
"BI"=3D"0"
"AB"=3D"0"
"ByteaAsLongVarBinary"=3D"0"
"UseServerSidePrepare"=3D"0"
"LowerCaseIdentifier"=3D"0"
"GssAuthUseGSS"=3D"0"
"SSLmode"=3D"disable"
"XaOpt"=3D"1"


--
Documento senza titolo