> -----Original Message----- > From: Gregory Stark [mailto:[EMAIL PROTECTED] > Sent: Monday, June 11, 2007 12:48 PM > To: Dann Corbit > Cc: pgsql-hackers@postgresql.org > Subject: Re: [HACKERS] Selecting a constant question > > "Dann Corbit" <[EMAIL PROTECTED]> writes: > > > SELECT 1 FROM test.dbo.a_003 > > > > gets about 60,000 records per second > > > > SELECT '1' FROM test.dbo.a_003 > > > > gets about 600 records per second. > > > > The cause is that postgres describes the return column as "unknown" > > length 65534 in the 2nd case. > > Wait, back up. How does this cause it to go slower?
The issue is this: Postgres describes the column with a typmod of -1 (unknown) and a length of 65534. This means that any client application must reserve 65534 bytes of spaces for every row of data (like a grid control for example), which postgres should know (and report) that the maximum length of the column is 1. This is not a PSQL issue, it's an issue with other products relying on the accuracy of the reported postgres metadata for a given SQL statement. ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq