Show max_identifier_length causes heavy query execution

Поиск
Список
Период
Сортировка
Искать

Show max_identifier_length causes heavy query execution

От:
Moreno D. <moreno.d@hotmail.it>
Дата:
Hello all,

I noticed that after executing a simple query that takes few milliseconds, the odbc driver executes another query which takes about 30 seconds to execute, because it scans a large table.
This is the part of the log file I think is showing the problem, see below for the entire log file:

[15.534]conn=02E72C78, query='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.552]    [ fetched 1 rows ]
[15.608]conn=02E72C78, query='show max_identifier_length'
[15.619]    [ fetched 1 rows ]
[15.660]STATEMENT ERROR: func=PGAPI_ColAttributes, desc='', errnum=30, errmsg='this request may be for MS SQL Server'

Then the driver executes the heavy query "SELECT * FROM az001.doc101", which retrieves about 1.5 million rows.

I came up with a workaround to avoid this problem, executing the query
SELECT (select count(*) from az001.doc101 where (code,riga)=(1,1))
instead of the original one, but this problem seems to appear in many points of the application, so i would like to find a better solution.

Here are some additional information,
the table structure is

CREATE TABLE az001.doc101
(
  code integer NOT NULL,
  riga integer NOT NULL,
  subriga integer NOT NULL,
  t_prog character varying(6) NOT NULL,
  fd_a character varying,
  fd_nd double precision,
  fd_il integer,
  fd_v double precision,
  fd_d timestamp with time zone,
  fd_sn boolean NOT NULL DEFAULT false,
  CONSTRAINT doc101_pkey PRIMARY KEY (code, riga, subriga, t_prog),
  CONSTRAINT doc101_code_fkey1 FOREIGN KEY (code, riga, subriga)
      REFERENCES az001.doc110 (code, riga, subriga) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (OIDS=FALSE);

and this is the entire log file:

[0.060]conn=02E72C78, PGAPI_DriverConnect( in)='DSN=PostgreSQL Log;', fDriverCompletion=0
[0.082]DSN info: DSN='PostgreSQL Log',server='localhost',port='5432',dbase='muna',user='client',passwd='xxxxx'
[0.091]          onlyread='0',protocol='7.4',showoid='0',fakeoidindex='0',showsystable='0'
[0.097]          conn_settings='', conn_encoding='(null)'
[0.100]          translation_dll='',translation_option=''
[0.116]Driver Version='08.03.0300,200809260001' linking 1400 static Multithread library
[0.123]Global Options: fetch=100, socket=4096, unknown_sizes=2, max_varchar_size=255, max_longvarchar_size=8190
[0.131]                disable_optimizer=0, ksqo=1, unique_index=1, use_declarefetch=0
[0.133]                text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1 NAMEDATALEN=64
[0.136]                extra_systable_prefixes='dd_;', conn_settings='' conn_encoding=''
[0.544]    [ PostgreSQL version string = '8.3.4' ]
[0.545]    [ PostgreSQL version number = '8.3' ]
[0.565]conn=02E72C78, query='select oid, typbasetype from pg_type where typname = 'lo''
[0.586]    [ fetched 0 rows ]
[0.601]    [ Large Object oid = -999 ]
[0.602]    [ Client encoding = 'UTF8' (code = 6) ]
[0.613]conn=02E72C78, PGAPI_DriverConnect(out)='DSN=PostgreSQL Log;DATABASE=muna;SERVER=localhost;PORT=5432;UID=client;PWD=xxxxxx;SSLmode=disable;ReadOnly=0;Protocol=7.4-1;FakeOidIndex=0;ShowOidColumn=0;RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=100;Socket=4096;UnknownSizes=2;MaxVarcharSize=255;MaxLongVarcharSize=8190;Debug=1;CommLog=1;Optimizer=0;Ksqo=1;UseDeclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0;BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTablePrefixes=dd_;;LFConversion=1;UpdatableCursors=1;DisallowPremature=0;TrueIsMinus1=0;BI=0;ByteaAsLongVarBinary=1;UseServerSidePrepare=0;LowerCaseIdentifier=0;XaOpt=1'
[15.534]conn=02E72C78, query='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.552]    [ fetched 1 rows ]
[15.608]conn=02E72C78, query='show max_identifier_length'
[15.619]    [ fetched 1 rows ]
[15.660]STATEMENT ERROR: func=PGAPI_ColAttributes, desc='', errnum=30, errmsg='this request may be for MS SQL Server'
[15.663]                 ------------------------------------------------------------
[15.664]                 hdbc=02E72C78, stmt=02E77808, result=02E70EA0
[15.665]                 prepare=0, internal=0
[15.666]                 bindings=02E791E8, bindings_allocated=1
[15.667]                 parameters=00000000, parameters_allocated=0
[15.668]                 statement_type=0, statement='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.670]                 stmt_with_params='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.671]                 data_at_exec=-1, current_exec_param=-1, put_data=0
[15.672]                 currTuple=-1, current_col=-1, lobj_fd=-1
[15.673]                 maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1
[15.674]                 cursor_name='SQL_CUR02E77808'
[15.675]                 ----------------QResult Info -------------------------------
[15.677]                 fields=02E77BA8, backend_tuples=02E78E70, tupleField=48729712, conn=02E72C78
[15.678]                 fetch_count=0, num_total_rows=1, num_fields=1, cursor='(NULL)'
[15.679]                 message='(NULL)', command='SELECT', notice='(NULL)'
[15.680]                 status=100, inTuples=0
[15.681]CONN ERROR: func=PGAPI_ColAttributes, desc='', errnum=0, errmsg='(NULL)'
[15.683]            ------------------------------------------------------------
[15.685]            henv=02E72C38, conn=02E72C78, status=1, num_stmts=16
[15.687]            sock=02E70A08, stmts=02E70AE0, lobj_type=-999
[15.688]            ---------------- Socket Info -------------------------------
[15.690]            socket=552, reverse=0, errornumber=0, errormsg='(NULL)'
[15.692]            buffer_in=48715736, buffer_out=48719856
[15.692]            buffer_filled_in=76, buffer_filled_out=0, buffer_read_in=76
[15.735]CONN ERROR: func=SQLNativeSqlW, desc='', errnum=-2, errmsg='Sql string too large'
[15.737]            ------------------------------------------------------------
[15.738]            henv=02E72C38, conn=02E72C78, status=1, num_stmts=16
[15.739]            sock=02E70A08, stmts=02E70AE0, lobj_type=-999
[15.740]            ---------------- Socket Info -------------------------------
[15.741]            socket=552, reverse=0, errornumber=0, errormsg='(NULL)'
[15.743]            buffer_in=48715736, buffer_out=48719856
[15.743]            buffer_filled_in=76, buffer_filled_out=0, buffer_read_in=76
[15.772]conn=02E72C78, query='SELECT * FROM az001.doc101'


Thanks in advance, I apologize for my poor english.

Regards,

Moreno Dissegna
Developer
S.A. Software S.r.l.

Scrivi, parla e gioca con i tuoi amici! Scarica Messenger 2009!

Re: Show max_identifier_length causes heavy query execution

От:
Ken Sell <ksell@greenplum.com>
Дата:
Hi,

I’m the new connectivity engineer.

I’m attempting to recreate the problem, but haven’t seen the same results as you.
Can you send me the sequence of ODBC statements that cause the problem?

Thanks,

....Ken Sell


On 5/26/09 9:48 AM, "Moreno D." <moreno.d@hotmail.it> wrote:

Hello all,

I noticed that after executing a simple query that takes few milliseconds, the odbc driver executes another query which takes about 30 seconds to execute, because it scans a large table.
This is the part of the log file I think is showing the problem, see below for the entire log file:

[15.534]conn=02E72C78, query='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.552]    [ fetched 1 rows ]
[15.608]conn=02E72C78, query='show max_identifier_length'
[15.619]    [ fetched 1 rows ]
[15.660]STATEMENT ERROR: func=PGAPI_ColAttributes, desc='', errnum=30, errmsg='this request may be for MS SQL Server'

Then the driver executes the heavy query "SELECT * FROM az001.doc101", which retrieves about 1.5 million rows.

I came up with a workaround to avoid this problem, executing the query
SELECT (select count(*) from az001.doc101 where (code,riga)=(1,1))
instead of the original one, but this problem seems to appear in many points of the application, so i would like to find a better solution.

Here are some additional information,
the table structure is

CREATE TABLE az001.doc101
(
  code integer NOT NULL,
  riga integer NOT NULL,
  subriga integer NOT NULL,
  t_prog character varying(6) NOT NULL,
  fd_a character varying,
  fd_nd double precision,
  fd_il integer,
  fd_v double precision,
  fd_d timestamp with time zone,
  fd_sn boolean NOT NULL DEFAULT false,
  CONSTRAINT doc101_pkey PRIMARY KEY (code, riga, subriga, t_prog),
  CONSTRAINT doc101_code_fkey1 FOREIGN KEY (code, riga, subriga)
      REFERENCES az001.doc110 (code, riga, subriga) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (OIDS=FALSE);

and this is the entire log file:

[0.060]conn=02E72C78, PGAPI_DriverConnect( in)='DSN=PostgreSQL Log;', fDriverCompletion=0
[0.082]DSN info: DSN='PostgreSQL Log',server='localhost',port='5432',dbase='muna',user='client',passwd='xxxxx'
[0.091]          onlyread='0',protocol='7.4',showoid='0',fakeoidindex='0',showsystable='0'
[0.097]          conn_settings='', conn_encoding='(null)'
[0.100]          translation_dll='',translation_option=''
[0.116]Driver Version='08.03.0300,200809260001' linking 1400 static Multithread library
[0.123]Global Options: fetch=100, socket=4096, unknown_sizes=2, max_varchar_size=255, max_longvarchar_size=8190
[0.131]                disable_optimizer=0, ksqo=1, unique_index=1, use_declarefetch=0
[0.133]                text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1 NAMEDATALEN=64
[0.136]                extra_systable_prefixes='dd_;', conn_settings='' conn_encoding=''
[0.544]    [ PostgreSQL version string = '8.3.4' ]
[0.545]    [ PostgreSQL version number = '8.3' ]
[0.565]conn=02E72C78, query='select oid, typbasetype from pg_type where typname = 'lo''
[0.586]    [ fetched 0 rows ]
[0.601]    [ Large Object oid = -999 ]
[0.602]    [ Client encoding = 'UTF8' (code = 6) ]
[0.613]conn=02E72C78, PGAPI_DriverConnect(out)='DSN=PostgreSQL Log;DATABASE=muna;SERVER=localhost;PORT=5432;UID=client;PWD=xxxxxx;SSLmode=disable;ReadOnly=0;Protocol=7.4-1;FakeOidIndex=0;ShowOidColumn=0;RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=100;Socket=4096;UnknownSizes=2;MaxVarcharSize=255;MaxLongVarcharSize=8190;Debug=1;CommLog=1;Optimizer=0;Ksqo=1;UseDeclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0;BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTablePrefixes=dd_;;LFConversion=1;UpdatableCursors=1;DisallowPremature=0;TrueIsMinus1=0;BI=0;ByteaAsLongVarBinary=1;UseServerSidePrepare=0;LowerCaseIdentifier=0;XaOpt=1'
[15.534]conn=02E72C78, query='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.552]    [ fetched 1 rows ]
[15.608]conn=02E72C78, query='show max_identifier_length'
[15.619]    [ fetched 1 rows ]
[15.660]STATEMENT ERROR: func=PGAPI_ColAttributes, desc='', errnum=30, errmsg='this request may be for MS SQL Server'
[15.663]                 ------------------------------------------------------------
[15.664]                 hdbc=02E72C78, stmt=02E77808, result=02E70EA0
[15.665]                 prepare=0, internal=0
[15.666]                 bindings=02E791E8, bindings_allocated=1
[15.667]                 parameters=00000000, parameters_allocated=0
[15.668]                 statement_type=0, statement='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.670]                 stmt_with_params='select count(*) from az001.doc101 where (code,riga)=(1,1)
'
[15.671]                 data_at_exec=-1, current_exec_param=-1, put_data=0
[15.672]                 currTuple=-1, current_col=-1, lobj_fd=-1
[15.673]                 maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1
[15.674]                 cursor_name='SQL_CUR02E77808'
[15.675]                 ----------------QResult Info -------------------------------
[15.677]                 fields=02E77BA8, backend_tuples=02E78E70, tupleField=48729712, conn=02E72C78
[15.678]                 fetch_count=0, num_total_rows=1, num_fields=1, cursor='(NULL)'
[15.679]                 message='(NULL)', command='SELECT', notice='(NULL)'
[15.680]                 status=100, inTuples=0
[15.681]CONN ERROR: func=PGAPI_ColAttributes, desc='', errnum=0, errmsg='(NULL)'
[15.683]            ------------------------------------------------------------
[15.685]            henv=02E72C38, conn=02E72C78, status=1, num_stmts=16
[15.687]            sock=02E70A08, stmts=02E70AE0, lobj_type=-999
[15.688]            ---------------- Socket Info -------------------------------
[15.690]            socket=552, reverse=0, errornumber=0, errormsg='(NULL)'
[15.692]            buffer_in=48715736, buffer_out=48719856
[15.692]            buffer_filled_in=76, buffer_filled_out=0, buffer_read_in=76
[15.735]CONN ERROR: func=SQLNativeSqlW, desc='', errnum=-2, errmsg='Sql string too large'
[15.737]            ------------------------------------------------------------
[15.738]            henv=02E72C38, conn=02E72C78, status=1, num_stmts=16
[15.739]            sock=02E70A08, stmts=02E70AE0, lobj_type=-999
[15.740]            ---------------- Socket Info -------------------------------
[15.741]            socket=552, reverse=0, errornumber=0, errormsg='(NULL)'
[15.743]            buffer_in=48715736, buffer_out=48719856
[15.743]            buffer_filled_in=76, buffer_filled_out=0, buffer_read_in=76
[15.772]conn=02E72C78, query='SELECT * FROM az001.doc101'


Thanks in advance, I apologize for my poor english.

Regards,

Moreno Dissegna
Developer
S.A. Software S.r.l.

Scrivi, parla e gioca con i tuoi amici! Scarica Messenger 2009! <http://messenger.it/gioca.aspx>

Re: Show max_identifier_length causes heavy query execution

От:
"Albe Laurenz" <laurenz.albe@wien.gv.at>
Дата:
Moreno D. wrote:
> I noticed that after executing a simple query that takes few 
> milliseconds, the odbc driver executes another query which 
> takes about 30 seconds to execute, because it scans a large table.
>
[...]
> 
> Then the driver executes the heavy query "SELECT * FROM 
> az001.doc101", which retrieves about 1.5 million rows.
> 
[...]
> 
> and this is the entire log file:
> 
[...]
> [0.613]conn=02E72C78, 
> PGAPI_DriverConnect(out)='DSN=PostgreSQL 
> Log;DATABASE=muna;SERVER=localhost;PORT=5432;UID=client;PWD=xx
> xxxx;SSLmode=disable;ReadOnly=0;Protocol=7.4-1;FakeOidIndex=0;
> ShowOidColumn=0;RowVersioning=0;ShowSystemTables=0;ConnSetting
> s=;Fetch=100;Socket=4096;UnknownSizes=2;MaxVarcharSize=255;Max
> LongVarcharSize=8190;Debug=1;CommLog=1;Optimizer=0;Ksqo=1;UseD
> eclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0;Bool
> sAsChar=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTablePrefixes=dd_
> ;;LFConversion=1;UpdatableCursors=1;DisallowPremature=0;TrueIs
> Minus1=0;BI=0;ByteaAsLongVarBinary=1;UseServerSidePrepare=0;Lo
> werCaseIdentifier=0;XaOpt=1'

Without the ODBC statements it is difficult to say something conclusive,
but it *might* be that you have the same problem I had some time ago.

I see that you set "Parse=0" in your connection options.
This will result in the ODBC driver executing "SELECT *"-Statements
when it needs to get a column description.

If that is the cause of your problem, then setting "Parse=1"
will fix it.

In ODBC Administrator on Windows, this option is called "Parse Statements"
and can be found in the advanced options page 1 (Button "Datasource").

Yours,
Laurenz Albe

Re: Show max_identifier_length causes heavy query execution

От:
Moreno D. <moreno.d@hotmail.it>
Дата:

>If that is the cause of your problem, then setting "Parse=1"
>will fix it.
> 
>In ODBC Administrator on Windows, this option is called "Parse Statements"
>and can be found in the advanced options page 1 (Button "Datasource").

Thank you Laurenz, setting "Parse=1" solved my problem!
Anyway, another problem appeared at another point in the application, i think this is the reason why that flag was turned off.
I simplified the query that gives the error, and obtained this :

    SELECT 1 as prog  UNION  SELECT code from aaa; --This one gives error

where aaa is a previously created table (If I create the table in the same statement, I don't get the error) :

    create table aaa(
    code integer   -- i tried also with character varying, it's the same
    );

If I write the two select in reverse order it works

    SELECT code as prog from aaa UNION  SELECT 1; --This one works

>Without the ODBC statements it is difficult to say something conclusive,

I attach below the log file, but I don't know what are the "ODBC statements"...Is it the "mylog" file? I'm using ADO components to connect to the database, so I don't know very much about ODBC, I'm sorry..

I analized the mylog in both cases and noticed this difference:

(This is the correct one)
[2956-2.138]parse_statement: entering...
[2956-2.138]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='SELECT', ptr='code as prog from aaa UNION  SELECT 1;
'
[2956-2.140]SELECT
[2956-2.140]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='code', ptr='as prog from aaa UNION  SELECT 1;
'
[2956-2.142]blevel=0 btoken=SELECT in_dot=0 in_field=0 tbname=
[2956-2.143]reallocing at nfld=0
[2956-2.144]got field='code', dot='(null)'
[2956-2.144]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='as', ptr='prog from aaa UNION  SELECT 1;
'
[2956-2.146]blevel=0 btoken=code in_dot=0 in_field=1 tbname=
[2956-2.147]got AS
[2956-2.147]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='prog', ptr='from aaa UNION  SELECT 1;
'
[2956-2.149]blevel=0 btoken=as in_dot=0 in_field=1 tbname=
[2956-2.149]alias for field 'code' is 'prog'
[2956-2.150]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='from', ptr='aaa UNION  SELECT 1;
'
[2956-2.152]First [2956-2.152]FROM
[2956-2.152]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='aaa', ptr='UNION  SELECT 1;
'
[2956-2.153]got table = 'aaa'
[2956-2.154]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='UNION', ptr='SELECT 1;
'
[2956-2.155]UNION...                       <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

(And this is the one that gives error)
[3244-1.937]parse_statement: entering...
[3244-1.937]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='SELECT', ptr='1 as prog  UNION  SELECT code from aaa;
'
[3244-1.939]SELECT
[3244-1.939]unquoted=1, quote=0, dquote=0, numeric=1, delim=' ', token='1', ptr='as prog  UNION  SELECT code from aaa;
'
[3244-1.941]blevel=0 btoken=SELECT in_dot=0 in_field=0 tbname=
[3244-1.942]reallocing at nfld=0
[3244-1.942]**** got numeric: nfld = 0
[3244-1.943]got field='(null)', dot='(null)'
[3244-1.944]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='as', ptr='prog  UNION  SELECT code from aaa;
'
[3244-1.945]blevel=0 btoken=1 in_dot=0 in_field=1 tbname=
[3244-1.946]got AS
[3244-1.946]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='prog', ptr='UNION  SELECT code from aaa;
'
[3244-1.948]blevel=0 btoken=as in_dot=0 in_field=1 tbname=
[3244-1.948]alias for field '(null)' is 'prog'
[3244-1.949]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='UNION', ptr='SELECT code from aaa;
'
[3244-1.951]blevel=0 btoken=prog in_dot=0 in_field=0 tbname=prog  
[3244-1.952]got field='UNION', dot='(null)' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
[3244-1.953]unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='SELECT', ptr='code from aaa;




This is psqlodbc_2008.log:
[0.007]Driver Version='08.03.0400,200811070001' linking 1400 static Multithread library
[0.015]Global Options: fetch=100, socket=4096, unknown_sizes=2, max_varchar_size=255, max_longvarchar_size=8190
[0.018]                disable_optimizer=0, ksqo=1, unique_index=1, use_declarefetch=0
[0.021]                text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1 NAMEDATALEN=64
[0.025]                extra_systable_prefixes='dd_;', conn_settings='' conn_encoding=''
[0.104]    [ PostgreSQL version string = '8.3.4' ]
[0.106]    [ PostgreSQL version number = '8.3' ]
[0.121]conn=031C2470, query='select oid, typbasetype from pg_type where typname = 'lo''
[0.139]    [ fetched 0 rows ]
[0.148]    [ Large Object oid = -999 ]
[0.150]    [ Client encoding = 'UTF8' (code = 6) ]
[0.161]conn=031C2470, PGAPI_DriverConnect(out)='DSN=PostgreSQL Log;DATABASE=muna;SERVER=localhost;PORT=5432;UID=client;PWD=xxxxxx;SSLmode=disable;ReadOnly=0;Protocol=7.4-1;FakeOidIndex=0;ShowOidColumn=0;RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=100;Socket=4096;UnknownSizes=2;MaxVarcharSize=255;MaxLongVarcharSize=8190;Debug=1;CommLog=1;Optimizer=0;Ksqo=1;UseDeclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0;BoolsAsChar=1;Parse=1;CancelAsFreeStmt=0;ExtraSysTablePrefixes=dd_;;LFConversion=1;UpdatableCursors=1;DisallowPremature=0;TrueIsMinus1=0;BI=0;ByteaAsLongVarBinary=1;UseServerSidePrepare=0;LowerCaseIdentifier=0;XaOpt=1'
[1.909]conn=031C2470, query='SELECT 1 as prog  UNION  SELECT code from aaa;
'
[1.922]    [ fetched 1 rows ]
[1.971]conn=031C2470, query='select current_schema()'
[1.989]    [ fetched 1 rows ]
[2.003]conn=031C2470, query='select nspname from pg_namespace n, pg_class c where c.relnamespace=n.oid and c.oid='"aaa"'::regclass'
[2.024]    [ fetched 1 rows ]
[2.095]conn=031C2470, query='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, d.adsrc from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and c.relname = E'aaa' and n.nspname = E'public') inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum> 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum'
[2.152]    [ fetched 1 rows ]
[2.289]PGAPI_Columns: table='aaa',field_name='code',type=23,name='int4'
[2.393]STATEMENT ERROR: func=PGAPI_DescribeCol, desc='Col#=1, #Cols=1,1 keys=2', errnum=13, errmsg='Invalid column number in DescribeCol.'
[2.397]                 ------------------------------------------------------------
[2.398]                 hdbc=031C2470, stmt=031C6FD0, result=031C72E8
[2.399]                 prepare=0, internal=0
[2.400]                 bindings=031C89E0, bindings_allocated=1
[2.401]                 parameters=00000000, parameters_allocated=0
[2.402]                 statement_type=0, statement='SELECT 1 as prog  UNION  SELECT code from aaa;
'
[2.403]                 stmt_with_params='SELECT 1 as prog  UNION  SELECT code from aaa;
'
[2.405]                 data_at_exec=-1, current_exec_param=-1, put_data=0
[2.406]                 currTuple=-1, current_col=-1, lobj_fd=-1
[2.406]                 maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1
[2.407]                 cursor_name='SQL_CUR031C6FD0'
[2.408]                 ----------------QResult Info -------------------------------
[2.409]                 fields=031C7398, backend_tuples=031C8698, tupleField=52201112, conn=031C2470
[2.411]                 fetch_count=0, num_total_rows=1, num_fields=1, cursor='(NULL)'
[2.412]                 message='(NULL)', command='SELECT', notice='(NULL)'
[2.414]                 status=100, inTuples=0
[2.415]CONN ERROR: func=PGAPI_DescribeCol, desc='Col#=1, #Cols=1,1 keys=2', errnum=0, errmsg='(NULL)'
[2.418]            ------------------------------------------------------------
[2.419]            henv=031C0A70, conn=031C2470, status=1, num_stmts=16
[2.420]            sock=031C0AA0, stmts=031C0B68, lobj_type=-999
[2.421]            ---------------- Socket Info -------------------------------
[2.422]            socket=552, reverse=0, errornumber=0, errormsg='(NULL)'
[2.423]            buffer_in=52187072, buffer_out=52191176
[2.424]            buffer_filled_in=456, buffer_filled_out=0, buffer_read_in=456
[3.990]conn=031C2470, PGAPI_Disconnect

Regards,

Moreno Dissegna
Developer
S.A. Software S.r.l.






_________________________________________________________________
Più di 100 Emoticon gratis per il tuo Messenger!
http://intrattenimento.it.msn.com/emoticon

Re: Show max_identifier_length causes heavy query execution

От:
Hiroshi Inoue <inoue@tpf.co.jp>
Дата:

psqlODBC Configuration Options

Advanced Options 1/2 Dialog Box

  • DEFAULTS: Press to this button restore the normal defaults for the settings described below.
     
  • Disable Genetic Optimizer: Automatically turns off the backend genetic optimizer at connection time. This is a convenience feature rather than having to type it in the connect settings. This feature was added when we noticed the backend seemed to have big problems optimizing some queries.
     
  • KSQO (Keyset Query Optimization): Deprecated for 7.1+ servers. Check this option when connecting 7.0- servers and the application seems to be suffering from the following kind of queries:

    select...where (a = 1 AND b = 1 AND c = 1) OR (a=1 AND b=1 AND c = 2)...
     
  • Recognize Unique Indexes: Check this option.
     
  • Use Declare/Fetch: If true, the driver automatically uses declare cursor/fetch to handle SELECT statements and keeps 100 rows in a cache. This is mostly a great advantage, especially if you are only interested in reading and not updating. It results in the driver not sucking down lots of memory to buffer the entire result set. If set to false, cursors will not be used and the driver will retrieve the entire result set. For very large tables, this is very inefficient and may use up all the Windows memory/resources. However, it may handle updates better since the tables are not kept open, as they are when using cursors. This was the style of the old podbc32 driver. However, the behavior of the memory allocation is much improved so even when not using cursors, performance should at least be better than the old podbc32.
     
  • CommLog (C:\psqlodbc_xxxx.log): Log communications to/from the backend to that file. This is good for debugging problems.
     
  • Parse Statements: Tell the driver how to gather the information about result columns of queries. See also Disallow Premature and ServerSide Prepare options.
    The driver checks this option first. If disabled then it checks the Server Side Prepare option. If disabled also it checks the Disallow Premature option.
    If neither of them is specified the driver would execute the prepared statement prematurely when the application inquires the result columns' info.

    If this option is enabled, the driver will parse an SQL query statement to identify the columns and tables and gather statistics about them such as precision, nullability, aliases, etc. It then reports this information in SQLDescribeCol, SQLColAttributes, and SQLNumResultCols. Prior to PostgreSQL 6.4, this was the only accurate way of getting information on precision from a query result.

    If the parser can not deal with a column (because it is a function or expression, etc.), it will fallback to executing the statement which is the old style of getting the info. The parser is fairly sophisticated and can handle many things such as column and table aliases, quoted identifiers, literals, joins, cross-products, etc. It can correctly identify a function or expression column, regardless of the complexity, but it does not attempt to determine the data type or precision of these columns.
     
  • Cancel as FreeStmt:
     
  • MyLog (C:\mylog_xxxx.log): Log debug messages to that file. This is good for debugging problems with the driver.
     
  • Unknown Sizes: This controls what SQLDescribeCol and SQLColAttributes will return as to precision for character data types (varchar, text, and unknown) in a result set when the precision is unknown. This was more of a workaround for pre-6.4 versions of PostgreSQL not being able to return the defined column width of the varchar data type.

    • Maximum: Always return the maximum precision of the data type.
    • Dont Know: Return "Don't Know" value and let application decide.
    • Longest: Return the longest string length of the column of any row. Beware of this setting when using cursors because the cache size may not be a good representation of the longest column in the cache.
      MS Access: Seems to handle Maximum setting ok, as well as all the others.
      Borland: If sizes are large and lots of columns, Borland may crash badly (it doesn't seem to handle memory allocation well) if using Maximum size.

  • Data Type Options: affects how some data types are mapped:
     
    • Text as LongVarChar: PostgreSQL TEXT type is mapped to SQLLongVarchar, otherwise SQLVarchar.
    • Unknowns as LongVarChar: Unknown types (arrays, etc) are mapped to SQLLongVarChar, otherwise SQLVarchar
    • Bools as Char: Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.

  • Max Varchar The maximum precision of the Varchar and BPChar(char[x]) types. The default is 254 which actually means 255 because of the null terminator. Note, if you set this value higher than 254, Access will not let you index on varchar columns!
     
  • Cache Size:When using cursors, this is the row size of the tuple cache. If not using cursors, this is how many tuples to allocate memory for at any given time. The default is 100 rows for either case.
     
  • Max LongVarChar: The maximum precision of the LongVarChar type. The default is 4094 which actually means 4095 with the null terminator. You can even specify (-4) for this size, which is the odbc SQL_NO_TOTAL value.
     
  • SysTable Prefixes: The additional prefixes of table names to regard as System Tables. The driver already treats names that begin with "pg_" as system tables. Here you can add additional ones, such as data dictionary tables (dd_). Separate each prefix with a semicolon (;)
     

Advanced Options 2/2 Dialog Box

  • ReadOnly: Whether the datasource will allow updates.
     
  • Show System Tables: The driver will treat system tables as regular tables in SQLTables. This is good for Access so you can see system tables.
     
  • LF <-> CR/LF conversion: Convert Unix style line endings to DOS style.
     
  • Updateable Cursors: Enable updateable cursor emulation in the driver.
     
  • Bytea as LO: Allow the use of bytea columns for Large Objects.
     
  • Row Versioning: Allows applications to detect whether data has been modified by other users while you are attempting to update a row. It also speeds the update process since every single column does not need to be specified in the where clause to update a row. The driver uses the "xmin" system field of PostgreSQL to allow for row versioning. Microsoft products seem to use this option well. See the faq for details on what you need to do to your database to allow for the row versioning feature to be used.
     
  • Disallow Premature: Mainly for 7.1 to 7.3 servers. Server side prepare is a more preferable option for 7.4+ servers.
    Tell the driver how to gather the information about result columns. See also Parse Staements and Server Side Prepare options.
    This is an option to compensate for the lack of a server's Prepare functionality. For example, (Middleware) applications issue the following ODBC API calls.

    SQLPreapare(hstmt, "select ...", ..)

    In most cases they have to know how many fields, what kind of fields they would return and so they would issue

    SQLNumResultCols and/or
    SQLDescribeCols/SQLColAttribute etc.

    The problem is how the psqlODBC driver answers the inquiry. PostgreSQL hadn't provided the Prepare functionality until 7.4 and we couldn't ask the backend about it directly. When using Disallow Premature, the driver will get the column info as follows:

       begin;(unless in a transaction)
       declare cursor .. for select ...
       fetch backward in ..
       close ..

    The driver gets the field info using the fetch backward's result. The fetch backward command returns no row but returns the field info. Though the command is expected to be returned immediately it isn't true for 7.0- servers unfortunately. The 7.1 or later servers do seem to return from the fetch backward command immediately.
     
  • True is -1: Represent TRUE as -1 for compatibility with some applications.
     
  • Server side prepare: Applicable for 7.3+ servers and recommended for 7.4+.
      (7.4+) Tell the driver how to gather the information about result columns. See also Parse Statement and Disallow Premature options.
            By using extended query protocol the driver replies to the inquiry correctly and effectively.
      (7.4+) By using extended query protocol the driver replies to the inquiry for the information of parameters.
      (7.3+) When using prepared statements, prepare them on the server rather than in the driver. This can give a slight performance advantage as the server
            doesn't need to re-parse the statement each time it is used.
     
  • Int8 As: Define what datatype to report int8 columns as.
     
  • Extra Opts: combination of the following bits.

      0x1: Force the output of short-length formatted connection string. Check this bit when you use MFC CDatabase class.
      0x2: Fake MS SQL Server so that MS Access recognizes PostgreSQL's serial type as AutoNumber type.
      0x4: Reply ANSI (not Unicode) char types for the inquiries from applications. Try to check this bit when your applications don't seem to be good at handling Unicode data.
     
  • Protocol: Note that when using SSL connections this setting is ignored.
     
    • 6.2: Forces driver to use PostgreSQL 6.2(V0) protocol, which had different byte ordering, protocol, and other semantics.
       
    • 6.3: Use the 6.3(V1) protocol. This is compatible with both V1(6.3) and V2(6.4 to 7.3) backends.
       
    • 6.4+: Use the 6.4(V2) protocol. This is only compatible with 6.4 and higher backends.
       
    • 7.4+: Use the 7.4(V3) protocol. This is only compatible with 7.4 and higher backends.
       
  • Level of rollback on errors: Specifies what to rollback should an error occur.
     
    • Nop(0): Don't rollback anything and let the application handle the error.
       
    • Transaction(1): Rollback the entire transaction.
       
    • Statement(2): Rollback the statement.
       
      Notes in a setup: This specification is set up with a PROTOCOL option parameter.

      PROTOCOL=[6.2|6.3|6.4|7.4][-(0|1|2)]
      default value is a sentence unit (it is a transaction unit before 8.0).

  • OID Options:
     
    • Show Column: Includes the OID in SQLColumns. This is good for using as a unique identifier to update records if no good key exists OR if the key has many parts, which blows up the backend.
       
    • Fake Index: This option fakes a unique index on OID. This is useful when there is not a real unique index on OID and for apps which can't ask what the unique identifier should be (i.e, Access 2.0).
       
  • Connect Settings: The driver sends these commands to the backend upon a successful connection.  It sends these settings AFTER it sends the driver "Connect Settings". Use a semi-colon (;) to separate commands. This can now handle any query, even if it returns results. The results will be thrown away however!
     

Global settings Dialog Box

This dialog allows you to specify pre-connection/default logging options

  • CommLog (C:\psqlodbc_xxxx.log - Communications log): Log communications to/from the backend to that file. This is good for debugging problems.
     
  • MyLog (C:\mylog_xxxx.log - Detailed debug output): Log debug messages to that file. This is good for debugging problems with the driver.
     
  • MSDTCLog (C:\pgdtclog\mylog_xxxx.log - MSDTC debug output): Log debug messages to that file. This is good for debugging problems with the MSDTC.
     
  • Specification of the holder for log outputs: Adjustment of write permission.
     

Manage DSN Dialog Box

This dialog allows you to select which PostgreSQL ODBC driver to use for this connection. Note that this may not work with third party drivers.

How to specify as a connection option

There is a method of specifying a connection option in a keyword strings.

Example:VBA

  • myConn = "ODBC;DRIVER={PostgreSQL};" & serverConn & _ "A0=0;A1=6.4;A2=0;A3=0;A4=0;A5=0;A6=;A7=100;A8=4096;A9=0;" & _ "B0=254;B1=8190;B2=0;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;" & _ "C0=0;C1=0;C2=dd_"

Please refer to a keyword list for details.

Re: Show max_identifier_length causes heavy query execution

От:
Moreno D. <moreno.d@hotmail.it>
Дата:
>Please look at the attached documentation especially about Parse
> Statements, ServerSide Prepare or Disallow Premature options.
Thank you Hiroshi,
I solved my problems setting ServerSide Prepare=1, Parse statements=0 and Disallow premature=0.
Thanks for the documentation, the next time I have problems I will read it carefully.
I would also thank Laurenz and Ken for the help.

Moreno Dissegna
Developer
S.A. Software S.r.l.



Personalizza Messenger 2009. Scegli la grafica che ti rappresenta meglio!
FAQ