Re: Selecting a constant question - Mailing list pgsql-hackers
From | Dann Corbit |
---|---|
Subject | Re: Selecting a constant question |
Date | |
Msg-id | D425483C2C5C9F49B5B7A41F8944154701000714@postal.corporate.connx.com Whole thread Raw |
In response to | Re: Selecting a constant question (Gregory Stark <stark@enterprisedb.com>) |
Responses |
Re: Selecting a constant question
Re: Selecting a constant question |
List | pgsql-hackers |
> -----Original Message----- > From: Gregory Stark [mailto:stark@enterprisedb.com] > Sent: Monday, June 11, 2007 2:41 PM > To: Dann Corbit > Cc: Martijn van Oosterhout; pgsql-hackers@postgresql.org; Larry McGhaw > Subject: Re: [HACKERS] Selecting a constant question > > "Dann Corbit" <DCorbit@connx.com> writes: > > > Surely, we cannot be the only people who will need this information. If > > (for example) someone wants to bind to a grid, then the maximum size has > > to be known in advance. > > In fact psql needs it and implements this. It has to skim through the > entire > result set to calculate the column widths. It's quite a lot of work but > the > server is in no better position to do it than psql. Reading the data twice sounds a little painful. What if there are 30 million rows? > On the contrary the server is missing quite a bit of information of how > you > intend to display the information. Do you need the number of bytes or > characters? Are all the characters the same width in your display system? > What > about currency symbols? Do you intend to reverse any quoting or just > display > backslashes? Giving me the information about the data type will be enough. As an example, in this case we have varchar data. If the server should be so kind as to report varchar(1) for '1' or varchar(3) for '123' then I would not have any difficulty binding the data to a grid. > Even knowing how many characters and assuming fixed character widths that > wouldn't even be enough to set your grid control widths. Usually people > like > numeric quantities decimal aligned and so two records "1.00" and "0.01" > will > take much more width than two records with "1.00" and "2.00". SQL*Server, Oracle, Ingres, DB/2 and other database systems somehow manage to do it, so I guess it is not technically intractable. I suspect that your own ODBC/JDBC and other drivers suffer from this same effect. Now, I do recognize that sometimes nobody is going to know how big something is, including the server. But with a query using a constant it seems like it ought to be well defined to me. Perhaps the difficulties are escaping me because I am not familiar with the low level guts of this problem. But I suspect that lots of people besides me would benefit if sizes of things were known when it is possible to know them. As I said before, I see that it cannot be known right now. So I am putting it in as a feature request. If you could be so kind as to point out the right spot to look in the server code, I imagine we could fix it and check in the patch ourselves.
pgsql-hackers by date: