From: mallah@trade-india.com
To: pgsql-admin@postgresql.org
Subject: \d tablename with psql over slow links...
Date: Sun, 23 Feb 2003 22:07:59 +0530 (IST)
Message-ID: <1042.219.65.235.8.1046018279.squirrel@mail.trade-india.com> (raw)
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' AND d.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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mallah@trade-india.com
Subject: Re: \d tablename with psql over slow links...
In-Reply-To: <1042.219.65.235.8.1046018279.squirrel@mail.trade-india.com>
References: <1042.219.65.235.8.1046018279.squirrel@mail.trade-india.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox