SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2004
    Location
    New York
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Increasing serial column: practical PgSQL trigger?

    Lets say I have a table with a smallint serial column. Would it be practical to create an INSERT statement trigger that checks to see if it reaches the smallint limit, and change it to an int? Or would the added procedure in every query make it not worth the effort?

    Hard disk space is not a factor.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    It's a bad and unfeasible idea. Why not just change the datatype?

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you get a serious performance penalty when changing a column type like that. if it was easy for a DB engine to handle such a change, then it wouldn't ask you up front for the size!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •