\d tablename with psql over slow links... - Mailing list pgsql-admin

From
Subject \d tablename with psql over slow links...
Date
Msg-id 1042.219.65.235.8.1046018279.squirrel@mail.trade-india.com
Whole thread Raw
Responses Re: \d tablename with psql over slow links...
Re: \d tablename with psql over slow links...
List pgsql-admin
Hi.

The \d tablename is too slow when its comes to usage over a dialup connection.

What i observed is that psql issues a sperate set of sql for getting default
value of each attribute if it has.  The number sqls increases  as the
size of table increases (no of attributes).

the information abt the default values can also be got by using a subselect
in the top level query which psql does to get list of attributes.

over local/fast links it may not be significant problem , but for dial up
connections it does.

I observed that a table which used to take 16 secs with \d was only taking
6 secs if the query for default attribute values are shifted to top level query in
psql/describe.c  ( function  describeOneTableDetails ) .

below is the diff  for describe.c

Any comments?


[root@subho psql]# diff -B ../safepsql/describe.c describe.c
638a639
>       unsigned int defaultcol = 5;
706a709,714
>
>       /* my code additions 1 */
>       appendPQExpBuffer(&buf, ", (SELECT substring(adsrc for 128)  FROM pg_catalog.pg_attrdef
>       WHERE adrelid =%s AND adnum = a.attnum ) "  , oid  );>       /* ends 1 */
>
>
760,768d775
<                               PGresult   *result;
<
<                               printfPQExpBuffer(&buf,
<                                                                 "SELECT substring(d.adsrc for
128) FROM pg_catalog.pg_attrdef d\n"<                                                          "WHERE d.adrelid = '%s'
ANDd.adnum = %s", 
<                                                                 oid, PQgetvalue(res, i, 4));
<
<                               result = PSQLexec(buf.data, false);
<
772d779
<                               strcat(cells[i * cols + 2], result ? PQgetvalue(result, 0, 0) : "?");
774c781,784
<                               PQclear(result);
---
>                               if (verbose)
>                                       defaultcol = 6;
>                               strcat(cells[i * cols + 2], PQgetvalue(res, i, defaultcol  ) );
>


-----------------------------------------
Get your free web based email at trade-india.com.
   "India's Leading B2B eMarketplace.!"
http://www.trade-india.com/



pgsql-admin by date:

Previous
From: "Aspire Something"
Date:
Subject: Date Return must be As per Natural Calander
Next
From: Tom Lane
Date:
Subject: Re: \d tablename with psql over slow links...