Re: Quoting table/column names vs performance - Mailing list pgsql-general

From Richard Huxton
Subject Re: Quoting table/column names vs performance
Date
Msg-id 47FCF54A.20901@archonet.com
Whole thread Raw
In response to Re: Quoting table/column names vs performance  (Jozef Ševčík <sevcik@styxsystems.com>)
Responses Re: Quoting table/column names vs performance  (Jozef Ševčík <sevcik@styxsystems.com>)
List pgsql-general
Jozef Ševčík wrote:
> Richard,
>
> thanks for the answer.
> In fact, I double-quoted identifiers only because PgSQL forced me to do so
> when using capitalized letters in table/column name.

Well, if you don't quote them they get folded to lower-case and you get
case-insensitive matching.

CREATE TABLE MyTable1 (a int); -- ends up as mytable1
CREATE TABLE "MyTable2" (a int); -- stays as MyTable2
SELECT * FROM MyTable1;  -- OK, looks for "mytable1"
SELECT * FROM MYTABLE1;  -- also OK
SELECT * FROM MyTaBlE1;  -- also OK
SELECT * FROM "MyTable1";-- Fails, looks for "MyTable1"
SELECT * FROM MyTable2;  -- Fails, looks for "mytable2"
SELECT * FROM "MyTable2"; -- OK

> I'm OK with this if it's PgSQL requirement (app runs on NHibernate so I just change
> column="MyColumn" to column="`MyColumn`" in mapping files).
>
> In fact I like capitalized column/table names (more readable for me),
> but the point is if this affect performance when running queries (for example PgSQL engine
> might take more time to analyze query with double-quoted identifiers or so).
>
> Is there any performance penalty for this ?

As I said, no cost you'll ever notice.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Terry Lee Tucker
Date:
Subject: Re: Disable Triggers
Next
From: Jozef Ševčík
Date:
Subject: Re: Quoting table/column names vs performance