Re: Advices on custom data type and extension development - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Advices on custom data type and extension development
Date
Msg-id CACjxUsMcZm91TW=aqnWW78gS6wuuif4wAXO3PeKLVTbzs-bUjQ@mail.gmail.com
Whole thread Raw
In response to Advices on custom data type and extension development  (Luciano Coutinho Barcellos <luciano@geocontrol.com.br>)
Responses Re: Advices on custom data type and extension development  (Corey Huinker <corey.huinker@gmail.com>)
List pgsql-hackers
On Mon, Jan 18, 2016 at 9:36 PM, Luciano Coutinho Barcellos
<luciano@geocontrol.com.br> wrote:

>         * a lot of data being generated every day, which are mainly queried
> by an immutable column of type date or timestamp;
>         * as a standard, almost every table has a bigserial id column as a
> primary key;
>         * data is huge enough to demand table partitioning, which is
> implemented as suggested in Postgres documentation, by using triggers and
> table inheritance. A function called by cron deal with creation of new
> partitions.
>
>     What I would like to develop first is a custom type (let's call it
> datedserial) for replacing bigserial as the primary key:
>
>         * the type would be 8 bytes long, being 4 dedicated to storing the
> Date, and 4 dedicated to storing a serial within that day;

Seriously, you should consider having a primary key with two
columns, of type date and int.  It would take exactly the same
space as your current plan, and performance should be very close to
what you propose.  As long as you aren't using some ORM that is too
dumb to deal with this, it should be far easier than creating the
custom type.

If you can't overcome the limitations of the "standard" or your
development framework any other way, you plan sounds like the next
best thing.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Re: [JDBC] 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Next
From: David Steele
Date:
Subject: Re: Additional role attributes && superuser review