Altering the size of autopk sequence by 3X default size | Community
Skip to main content
May 9, 2021
Solved

Altering the size of autopk sequence by 3X default size

  • May 9, 2021
  • 1 reply
  • 2237 views

Hello,

 

I want to know how can we alter the size of the dafault autopk, there is something with custom autopk/pksequence, but I am unable to find How to make the autopk size - 3X of its default one?'

 

Thanks.

Komal

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jonathon_wodnicki

Hi,

 

Autopk sequence goes by rdbms' capability and can be altered as needed, e.g. alter sequence ... maxvalue 99999.

Be mindful of the key's size, default autopk is 32 bit signed integer = ~2B max value.

Changing the field size by adding this attribute could work but sounds like something that would break warranty:

  • <attribute name="id" type="int64"/>

 

Thanks,

-Jon

1 reply

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
May 9, 2021

Hi,

 

Autopk sequence goes by rdbms' capability and can be altered as needed, e.g. alter sequence ... maxvalue 99999.

Be mindful of the key's size, default autopk is 32 bit signed integer = ~2B max value.

Changing the field size by adding this attribute could work but sounds like something that would break warranty:

  • <attribute name="id" type="int64"/>

 

Thanks,

-Jon

SKomal76Author
May 10, 2021

Hi Jon,

 

After gathering a lot of information, I think we can use pksequence to alter the default size of autopk which we mention in the main element of the schema body.

 

By default autopk takes 32 bit size and enrolled its pksequence under "XtkNewId" by default, yes, we don't mention this.

 

Now let's say I wanted to make its size of 64 bit, now I want to know under which schema(instead of XtkNewId) we can store this updated default size of autopk?

I referred: Database mapping | Adobe Campaign

 

A snippet from  Database mapping | Adobe Campaign

NOTE

A sequence referenced in an Adobe Campaign schema (NmsTrackingLogId for example) must be associated to a SQL function that returns the number of IDs in the parameters, separated by commas. This function must be called GetNewXXXIds, where XXX is the name of the sequence (GetNewNmsTrackingLogIds for example). View the postgres-nms.sqlmssql-nms.sql or oracle-nms.sql files provided with the appliation in the datakit/nms/eng/sql/ directory to recover the example of a ‘NmsTrackingLogId’ sequence creation for each database engine.

 

 

Also, as per my knowledge we can't exceed the size of 64 bit using pksequence for autopk, please reflect your knowledge on this point as well.

 

Thanks.

Komal