Re: Quoting table/column names vs performance

From: Jozef Ševčík <sevcik(at)styxsystems(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Quoting table/column names vs performance
Date: 2008-04-09 15:55:31
Message-ID: D2C6AB7E6EDFD94788D27D1F537FCC3806176F640A@VMBX102.ihostexchange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.
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 ?

S pozdravom / Best regards,

Jozef Ševčík
sevcik(at)styxsystems(dot)com
+420 608 782 813

-----Original Message-----
From: Richard Huxton [mailto:dev(at)archonet(dot)com]
Sent: Wednesday, April 09, 2008 5:49 PM
To: Jozef Ševčík
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Quoting table/column names vs performance

Jozef Ševčík wrote:
> Hi all,
>
> I just switched from MS SQL to PostgreSQL on project and have
> question about double-quoting names of fields/tables regarding to
> performance.

If the cost of quoting column-names is a significant part of your query
costs, you must have some very fast queries. I would not worry.

> In MSSQL I had something like: SELECT Column1,Column2 from MyTable
>
> In PgSQL I write: SELECT "Column1", "Column2" from "MyTable"
>
> Which is fine and working, I have no doubt about it. I'm just
> guessing if this does not affect performance in any way. I know I may
> rename tables/fields to lowercase and avoid double-quotting, but it
> double-quotting has no affect on perf. is it worth it ? Or are there
> any advantages of using 'non-quoted' identifiers agains double-quoted

If you double-quote identifiers when you create them you'll want to
double-quote them everywhere they are used. That's OK with a new sytem,
but can be awkward if you have a lot of existing code that isn't already
quoted.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2008-04-09 16:02:05 Re: Problem with windows Postgres 8.3.1 MSI binary distribution
Previous Message Richard Huxton 2008-04-09 15:48:53 Re: Quoting table/column names vs performance