Search Postgresql Archives

Re: SELECT * and column ordering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2013-01-16, Meta Seller Dev/Admin <metaseller@xxxxxxxxx> wrote:
> Hi! (I'm Chris Angelico posting from a work account - usually I'm here
> under the name rosuav@xxxxxxxxx.)
>
> I've run into a bit of an awkwardness in PostgreSQL setup and am
> hoping for some expert advice.
>
> Several of the tables I work with have two groups of fields: standard
> fields and "free fields". The standard fields have fixed names and
> will always exist; the free fields could be anything. In many cases, I
> want to enumerate all fields, including free ones, and for that I use
> "SELECT * FROM tablename".
>
> Normally, the standard fields are at the beginning of the table,
> having been created first. This is very convenient, as it lets me
> iterate over them first, and then pick up the free fields after. (Or
> alternatively, pick up a specific standard field by its index.) New
> free fields can be created at any time, and the program will happily
> pick them up and work with them. Order among free fields never
> matters.

walking the list of column names you get back from "select *" is likely
to be faster than any of the other options, and you only need to do it
once and (and then store the indices of the interesting columns in an array for
later reference.)

PQgetvalue() has O(1) complexity so once you know the column number 
you want the cost is the same.

-- 
⚂⚃ 100% natural



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux